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/netwerkbrabant/netwerkbrabant.nl/app/KommaApp/EventSignUps/Models/EventSignUp.php
<?php


namespace App\KommaApp\EventSignUps\Models;


use App\KommaApp\Events\Models\Event;
use App\KommaApp\Kms\Core\Entities\DisplayNameTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Str;

class EventSignUp extends Model
{
    use SoftDeletes;

    protected $table = 'event_sign_ups';

    protected $fillable = ['event_id', 'company', 'first_name', 'last_name', 'email',  'phone', 'site', 'particularities'];

    /*
    * Transient properties on Eloquent models
    * These are not saved to database.
    */
    public $thumbnail = false;

    public function event():BelongsTo
    {
        return $this->belongsTo(Event::class);
    }

    /**
     * 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;

        // First try to get the name of the model
        if(isset($this->first_name) && $this->first_name != '') {
            return $this->first_name;
        }

        return null;
    }

    /**
     * @return string
     */
    public function getSideBarName():string
    {
        // If there is no name defined generate a generic name
        if(!$sideBarName = $this->getDisplayName()){
            $sideBarName = trans( 'kms/'.Str::camel($this->table).'.section.entity') . ' ' . $this->id;
        }
        return $sideBarName;
    }

}