![]() 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/Jobs/Models/ |
<?php namespace Corals\Modules\Jobs\Models; use Corals\Foundation\Models\BaseModel; use Corals\Foundation\Transformers\PresentableTrait; use Corals\Modules\Utility\Models\Address\Location; use Corals\Modules\Utility\Models\ListOfValue\ListOfValue; use Corals\Modules\Utility\Traits\Gallery\ModelHasGallery; use Corals\Modules\Utility\Traits\Rating\ReviewRateable as ReviewRateableTrait; use Corals\User\Models\User; use Spatie\Activitylog\Traits\LogsActivity; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; class Employer extends BaseModel implements HasMedia { use PresentableTrait, LogsActivity, ModelHasGallery, InteractsWithMedia, ReviewRateableTrait; /** * Model configuration. * @var string */ public $config = 'jobs.models.employer'; public $galleryMediaCollection = 'jobs-employer-gallery'; public $mediaCollectionName = 'jobs-employer-thumbnail'; protected static $logAttributes = []; protected $table = 'jo_employers'; protected $casts = [ 'properties' => 'json', ]; protected $guarded = ['id']; public function fieldCode() { return $this->belongsTo(ListOfValue::class, 'field_code', 'code'); } public function jobs() { return $this->hasMany(Job::class, 'owner_id'); } public function user() { return $this->belongsTo(User::class); } public function location() { return $this->belongsTo(Location::class); } public function branch() { return $this->hasMany(Branch::class); } public function getNonFeaturedImageAttribute() { $image = asset(config($this->config . '.default_image')); $gallery = $this->getMedia($this->galleryMediaCollection); foreach ($gallery as $item) { if (!$item->hasCustomProperty('featured')) { $image = $item->getFullUrl(); break; } } return $image; } }