GoodsModel.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Models;
  12. /**
  13. * 商品-模型
  14. * @author laravel开发员
  15. * @since 2020/11/11
  16. * @package App\Models
  17. */
  18. class GoodsModel extends BaseModel
  19. {
  20. // 设置数据表
  21. protected $table = 'goods';
  22. public function sku_list()
  23. {
  24. }
  25. /**
  26. * 商品规格
  27. * @return \Illuminate\Database\Eloquent\Relations\HasMany
  28. */
  29. public function skuList()
  30. {
  31. return $this->hasMany(GoodsSkuModel::class, 'goods_id','goods_id')
  32. ->where(['status'=>1,'mark'=>1]);
  33. }
  34. /**
  35. * 商品规格(所有)
  36. * @return \Illuminate\Database\Eloquent\Relations\HasMany
  37. */
  38. public function skuAll()
  39. {
  40. return $this->hasMany(GoodsSkuModel::class, 'goods_id','goods_id')
  41. ->where(['mark'=>1]);
  42. }
  43. }