GoodsModel.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. /**
  44. * 分类
  45. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  46. */
  47. public function category()
  48. {
  49. return $this->hasOne(GoodsCategoryModel::class, 'cate_id','cate_id')
  50. ->where(['mark'=>1])
  51. ->select(['id','name','pid','cate_id','status']);
  52. }
  53. }