1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace App\Models;
- use Dcat\Admin\Traits\HasDateTimeFormatter;
- use Illuminate\Database\Eloquent\SoftDeletes;
- use Illuminate\Database\Eloquent\Model;
- class Product extends Model
- {
- use HasDateTimeFormatter;
- use SoftDeletes;
- protected $table = 'product';
- protected $fillable = [
- 'type',
- 'user_id',
- 'name',
- 'content',
- 'image',
- 'status',
- 'url',
- 'like_count'
- ];
- protected $casts = [
- 'type'=>'array'
- ];
- public function type(){
- return $this->hasOne(ProductType::class,'id','type');
- }
- public function user(){
- return $this->hasOne(User::class,'id','user_id');
- }
- }
|