![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/job-board.corals.io/Corals/modules/Classified/Models/ |
<?php namespace Corals\Modules\Classified\Models; use Corals\Foundation\Models\BaseModel; use Corals\Foundation\Search\Indexable; use Corals\Foundation\Transformers\PresentableTrait; use Corals\Modules\Utility\Models\Address\Location; use Corals\Modules\Utility\Traits\Category\ModelHasCategory; use Corals\Modules\Utility\Traits\Gallery\ModelHasGallery; use Corals\Modules\Utility\Traits\Tag\HasTags; use Corals\Modules\Utility\Traits\Wishlist\Wishlistable; use Corals\User\Models\User; use Cviebrock\EloquentSluggable\Sluggable; use Spatie\Activitylog\Traits\LogsActivity; use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\HasMedia; use Corals\Modules\Utility\Traits\Rating\ReviewRateable as ReviewRateableTrait; class Product extends BaseModel implements HasMedia { use Indexable, Sluggable, PresentableTrait, ModelHasGallery, LogsActivity, InteractsWithMedia , ReviewRateableTrait, Wishlistable, HasTags, ModelHasCategory; public $galleryMediaCollection = 'classified-product-gallery'; /** * Model configuration. * @var string */ public $config = 'classified.models.product'; protected $casts = [ 'properties' => 'array', 'is_featured' => 'boolean', 'price_on_call' => 'boolean' ]; protected $guarded = ['id']; protected $indexContentColumns = ['description', 'caption']; protected $indexTitleColumns = ['name', 'tags.name', 'tags.slug', 'categories.name']; protected $table = 'classified_products'; public function getModuleName() { return 'Classified'; } public function sluggable() { return [ 'slug' => [ 'source' => 'name' ] ]; } public function location() { return $this->belongsTo(Location::class); } public function scopeActive($query) { return $query->where('classified_products.status', 'active'); } public function scopeByCondition($query, $condition) { return $query->where('condition', $condition); } public function scopeByStatus($query, $status) { return $query->where('status', $status); } public function scopeAuthUser($query) { return $query->where('user_id', user()->id); } public function scopeFeatured($query) { return $query->where('classified_products.is_featured', true); } public function user() { return $this->belongsTo(User::class); } public function getCurrencyAttribute() { $currency = \Payments::admin_currency_code(); return $currency; } public function getCurrencyIconAttribute() { $currency = $this->currency; return 'fa fa-fw fa-' . strtolower($currency); } public function getShowURL($id = null, $params = []) { return urlWithParameters("products/{$this->slug}", $params); } public function getLocation() { if (\Settings::get('classified_enable_google_location', false)) { return $this->address; } else { return $this->location->name; } } public function getStoreName() { $store_name = $this->user->getProperty('store_name'); if ($store_name) { return $store_name; } else { return $this->user->full_name; } } public function getLocationSlug() { if (\Settings::get('classified_enable_google_location', false)) { return url('products?zipcode=' . $this->zip_code); } else { return url('products?location=' . $this->location->slug); } } public function getDisplayReference() { return $this->name; } }