Product.php 698 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Models;
  3. use Dcat\Admin\Traits\HasDateTimeFormatter;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. use Illuminate\Database\Eloquent\Model;
  6. class Product extends Model
  7. {
  8. use HasDateTimeFormatter;
  9. use SoftDeletes;
  10. protected $table = 'product';
  11. protected $fillable = [
  12. 'type',
  13. 'user_id',
  14. 'name',
  15. 'content',
  16. 'image',
  17. 'status',
  18. 'url',
  19. 'like_count'
  20. ];
  21. protected $casts = [
  22. 'type'=>'array'
  23. ];
  24. public function type(){
  25. return $this->hasOne(ProductType::class,'id','type');
  26. }
  27. public function user(){
  28. return $this->hasOne(User::class,'id','user_id');
  29. }
  30. }