File: D:/HostingSpaces/SBogers10/rentman2019.komma.pro/app/Komma/Jobs/Models/Job.php
<?php
/**
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
namespace App\Komma\Jobs\Models;
use App\Komma\Documents\DocumentsTrait;
use App\Komma\Documents\Kms\DocumentableInterface;
use App\Komma\Kms\Core\Entities\DisplayNameInterface;
use App\Komma\Kms\Core\Entities\DisplayNameTrait;
use App\Komma\Kms\Core\NestedSets\Nodes\AbstractTranslatableTreeModel;
use App\Komma\Languages\Models\Language;
use App\Komma\Sites\HasSiteInterface;
use App\Komma\Sites\Models\Site;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* Class Page
*
* @property int site_id
* @property int lft
* @property int rgt
* @property int tree
* @property-read \Carbon $date
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Komma\Languages\Models\Language[] $languages
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Komma\Sites\Models\Site[] $sites
* @property-read \App\Komma\Jobs\Models\JobTranslation $translation
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Komma\Jobs\Models\JobTranslation[] $translations
* @mixin \Eloquent
* @property int $id
* @property int $active
* @property \Carbon\Carbon|null $created_at
* @property \Carbon\Carbon|null $jobd_at
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Jobs\Models\Job whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Jobs\Models\Job whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Jobs\Models\Job whereDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Jobs\Models\Job whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Jobs\Models\Job whereJobdAt($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Komma\Documents\Models\Document[] $documents
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Komma\Documents\Models\Document[] $images
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Jobs\Models\Job newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Jobs\Models\Job newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Jobs\Models\Job query()
*/
class Job extends AbstractTranslatableTreeModel implements HasSiteInterface, DocumentableInterface, DisplayNameInterface
{
use DocumentsTrait;
use DisplayNameTrait;
protected $table = 'jobs';
protected $class = self::class;
protected $fillable = ['site_id', 'lft', 'rgt', 'tree', 'created_at', 'updated_at'];
/**
* Gets the translation models for this model
*
* @return HasMany that resolves to AbstractTranslationModel instances
*/
public function translations(): HasMany
{
return $this->hasMany(JobTranslation::class);
}
public function languages(): BelongsToMany
{
return $this->belongsToMany(Language::class, 'job_translations')
->withPivot('slug', 'name', 'description')
->withTimestamps();
}
/**
* Get the site for this this model
*
* @return belongsTo
*/
public function site(): BelongsTo
{
return $this->belongsTo(Site::class, 'site_id'); //Model must have site_id attribute
}
public function __get($key)
{
if ($key == 'parent_id') {
if ($this::find($this->id)) {
return $this->getParentId();
}
}
return parent::__get($key);
}
}