33 lines
659 B
PHP
33 lines
659 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Good extends Model
|
|
{
|
|
use HasDateTimeFormatter;
|
|
|
|
public function goods_attrs(){
|
|
return $this->hasMany(GoodsAttr::class, 'goods_id');
|
|
}
|
|
|
|
public function useGoodsAttrs(){
|
|
return $this->hasMany(GoodsAttr::class, 'goods_id')->where('is_use', 1);
|
|
}
|
|
|
|
public function activityExchange(){
|
|
return $this->hasOne(ActivityGood::class, 'goods_id');
|
|
}
|
|
|
|
public function category(){
|
|
return $this->belongsTo(GoodsCategory::class, 'category_id');
|
|
}
|
|
|
|
public function type(){
|
|
return $this->belongsTo(GoodsType::class, 'type_id');
|
|
}
|
|
}
|