BaseProduct.php 552 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\Model;
  5. class BaseProduct extends Model
  6. {
  7. use HasDateTimeFormatter;
  8. protected $table = 'base_product';
  9. protected $casts = [
  10. 'created_at' => 'datetime:Y-m-d H:i:s',
  11. 'updated_at' => 'datetime:Y-m-d H:i:s',
  12. 'parameters' => 'json', // 将 attributes 字段转换为数组
  13. ];
  14. public function baseProductCategory()
  15. {
  16. return $this->hasOne(BaseProductCategory::class,'id','category_id');
  17. }
  18. }