File: D:/HostingSpaces/SBogers10/farmfun.komma.pro/app/Komma/CalendarNotes/Models/CalendarNote.php
<?php
namespace App\Komma\CalendarNotes\Models;
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\Locations\Models\Location;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* Class CalendarNote
*
* @property-read \App\Komma\Globalization\Languages\Models\Language[] $languages
* @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\CalendarNotes\Models\CalendarNote whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\CalendarNotes\Models\CalendarNote whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\CalendarNotes\Models\CalendarNote whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\CalendarNotes\Models\CalendarNote whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\CalendarNotes\Models\CalendarNote newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\CalendarNotes\Models\CalendarNote newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Komma\CalendarNotes\Models\CalendarNote query()
*/
final class CalendarNote extends Model implements DisplayNameInterface, HasThumbnailInterface
{
use HasThumbnailTrait;
use DisplayNameTrait;
protected $class = self::class;
protected $protected = ['id', 'location_id'];
// protected $dates = ['date'];
protected $dates = ['start_date', 'end_date'];
public function location():BelongsTo
{
return $this->belongsTo(Location::class);
}
public function getSidebarName(): string
{
$sideBarName = $this->name.' | '.$this->start_date->format('d-m-Y');
if ($this->end_date->format('d-m-Y') != $this->start_date->format('d-m-Y')) {
$sideBarName .= ' tot '.$this->end_date->format('d-m-Y');
}
$sideBarName .= '<br/><small>'.$this->location->translation->name.'</small>';
return $sideBarName;
}
public function getDisplayName(): ?string
{
if (! isset($this->location)) {
return $this->id;
}
$sideBarName = $this->location->translation->name.' | '.$this->name;
return $sideBarName;
}
}