mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 14:56:13 -06:00
added attributes
This commit is contained in:
parent
88342891f6
commit
bcf326c767
@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvInterface;
|
||||
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
|
||||
use Visiosoft\AdvsModule\Support\Command\Currency;
|
||||
use Visiosoft\LocationModule\City\CityModel;
|
||||
use Visiosoft\LocationModule\Country\CountryModel;
|
||||
use Visiosoft\CartsModule\Cart\Command\GetCart;
|
||||
@ -17,6 +18,45 @@ use Visiosoft\LocationModule\Village\Contract\VillageRepositoryInterface;
|
||||
|
||||
class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
{
|
||||
protected $appends = [
|
||||
'detail_url',
|
||||
'currency_price',
|
||||
'cat1_name',
|
||||
'cat2_name',
|
||||
'thumbnail',
|
||||
];
|
||||
|
||||
public function getDetailUrlAttribute()
|
||||
{
|
||||
return $this->getAdvDetailLinkByModel($this, 'list');
|
||||
}
|
||||
|
||||
public function getCurrencyPriceAttribute()
|
||||
{
|
||||
return app(Currency::class)->format($this->price, $this->currency);
|
||||
}
|
||||
|
||||
public function getCat1NameAttribute()
|
||||
{
|
||||
return $this->hasMany('Visiosoft\CatsModule\Category\CategoryModel', 'id', 'cat1')->first()->name;
|
||||
|
||||
}
|
||||
|
||||
public function getCat2NameAttribute()
|
||||
{
|
||||
return $this->hasMany('Visiosoft\CatsModule\Category\CategoryModel', 'id', 'cat1')->first()->name;
|
||||
|
||||
}
|
||||
|
||||
public function getThumbnailAttribute()
|
||||
{
|
||||
if ($this->cover_photo == null) {
|
||||
return $this->dispatch(new MakeImageInstance('visiosoft.theme.base::images/no-image.png', 'img'))->url();
|
||||
} else {
|
||||
return url($this->cover_photo);
|
||||
}
|
||||
}
|
||||
|
||||
public function getTransNameAttribute()
|
||||
{
|
||||
if (is_null($this->name)) {
|
||||
@ -278,12 +318,10 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
|
||||
public function stockControl($id, $quantity)
|
||||
{
|
||||
if($adv = $this->getAdv($id))
|
||||
{
|
||||
if ($adv = $this->getAdv($id)) {
|
||||
$stock = $adv->stock;
|
||||
|
||||
if($stock and $stock >= $quantity)
|
||||
{
|
||||
if ($stock and $stock >= $quantity) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -389,11 +389,6 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
|
||||
$ads = $this->model->getLocationNames($latest_advs);
|
||||
|
||||
foreach ($ads as $index => $ad) {
|
||||
$ads[$index]->detail_url = $this->model->getAdvDetailLinkByModel($ad, 'list');
|
||||
$ads[$index] = $this->model->AddAdsDefaultCoverImage($ad);
|
||||
}
|
||||
|
||||
return $ads;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user