ProductInfoModel.php 957 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Models;
  3. use App\Models\BaseModel;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. /**
  6. * @description 产品规格
  7. * @author system;
  8. * @version 1.0
  9. * @date 2018-07-12 08:29:26
  10. *
  11. */
  12. class ProductInfoModel extends BaseModel
  13. {
  14. use SoftDeletes;
  15. /**
  16. * 数据表名
  17. *
  18. * @var string
  19. *
  20. */
  21. protected $table = 'product_info';
  22. /**
  23. * 主键
  24. */
  25. protected $primaryKey = 'id';
  26. //分页
  27. protected $perPage = PAGE_NUMS;
  28. /**
  29. * 可以被集体附值的表的字段
  30. *
  31. * @var string
  32. */
  33. protected $fillable = [
  34. 'name',
  35. 'category_id',
  36. 'origin_price',
  37. 'current_price',
  38. 'deposit',
  39. 'service_time',
  40. 'sort'
  41. ];
  42. public function catename(){
  43. return (new ProductCategoryModel())->find($this->category_id)?(new ProductCategoryModel())->find($this->category_id)->name:$this->category_id;
  44. }
  45. }