Product.php 676 B

12345678910111213141516171819202122232425262728293031323334353637
  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. ];
  20. protected $casts = [
  21. 'type'=>'array'
  22. ];
  23. public function type(){
  24. return $this->hasOne(ProductType::class,'id','type');
  25. }
  26. public function user(){
  27. return $this->hasOne(User::class,'id','user_id');
  28. }
  29. }