HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/inzigd.komma.pro/app/Komma/Employees/Models/Employee.php
<?php
/**
 *
 *
 * @author      Komma <info@komma.pro>
 * @copyright   (c) 2012-2016, Komma
 */

namespace App\Komma\Employees\Models;

use App\Komma\Documents\DocumentsTrait;
use App\Komma\Documents\Kms\DocumentableInterface;
use App\Komma\Kms\Core\Attributes\Models\Traits\HasThumbnailInterface;
use App\Komma\Kms\Core\Attributes\Models\Traits\HasThumbnailTrait;
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 Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
 * Class Page
 *
 * @package App\Komma\Pages\Models
 * @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\Employees\Models\EmployeeTranslation $translation
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Komma\Employees\Models\EmployeeTranslation[] $translations
 * @mixin \Eloquent
 * @property int $id
 * @property int $active
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Employees\Models\Employee whereActive($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Employees\Models\Employee whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Employees\Models\Employee whereDate($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Employees\Models\Employee whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Employees\Models\Employee whereUpdatedAt($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\Employees\Models\Employee newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Employees\Models\Employee newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\Employees\Models\Employee query()
 */
class Employee extends Model implements DocumentableInterface, DisplayNameInterface, HasThumbnailInterface
{
    use DocumentsTrait;
    use DisplayNameTrait;
    use HasThumbnailTrait;

    protected $table = 'employees';
    protected $class = Employee::class;

    protected $fillable = ['first_name', 'last_name', 'phone_display', 'phone_call', 'email'];


    public function languages(): BelongsToMany
    {
        return $this->belongsToMany(Language::class, 'employee_translations')
            ->withPivot('slug', 'name', 'description')
            ->withTimestamps();
    }

    /**
     * Get the name of this model by model or translation model
     *
     * @return null|string
     */
    public function getDisplayName():?string
    {
        // If it is a new model the section name will filled by model.section.new
        if(!$this->exists) return null;

        return $this->first_name . ' ' . $this->last_name;
    }
}