category relation

This commit is contained in:
vedatakd 2021-06-21 12:30:09 +03:00
parent bcf326c767
commit bb150fabb4

View File

@ -21,8 +21,8 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
protected $appends = [ protected $appends = [
'detail_url', 'detail_url',
'currency_price', 'currency_price',
'cat1_name', 'category1',
'cat2_name', 'category2',
'thumbnail', 'thumbnail',
]; ];
@ -36,15 +36,15 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
return app(Currency::class)->format($this->price, $this->currency); return app(Currency::class)->format($this->price, $this->currency);
} }
public function getCat1NameAttribute() public function getCategory1Attribute()
{ {
return $this->hasMany('Visiosoft\CatsModule\Category\CategoryModel', 'id', 'cat1')->first()->name; return $this->hasMany('Visiosoft\CatsModule\Category\CategoryModel', 'id', 'cat1')->first();
} }
public function getCat2NameAttribute() public function getCategory2Attribute()
{ {
return $this->hasMany('Visiosoft\CatsModule\Category\CategoryModel', 'id', 'cat1')->first()->name; return $this->hasMany('Visiosoft\CatsModule\Category\CategoryModel', 'id', 'cat1')->first();
} }