This commit is contained in:
2025-06-18 14:50:18 +03:00
parent a64ed080bb
commit 4c716a8a8c
160 changed files with 6786 additions and 23 deletions

View File

@ -0,0 +1,110 @@
<?php
namespace kernel\app_modules\event\models;
use DateTime;
use Illuminate\Database\Eloquent\Model;
use kernel\helpers\Debug;
// Добавить @property
/**
* @property int $id
* @property int $status
* @property int $hours_count
* @property string $title
* @property string $type
* @property string $date_start
* @property string $dateStartFormated
* @property string $dateStartFormatedToForm
* @property string $dateEndFormatedToForm
* @property string $dateEndFormated
* @property string $date_end
* @property string $place
* @property string $event_format
* @property string $description
* @property string $additional_info
*/
class Event extends Model
{
const DISABLE_STATUS = 0;
const ACTIVE_STATUS = 1;
protected $table = 'event';
protected $fillable = ['title', 'type', 'hours_count', 'date_start', 'date_end', 'place', 'event_format', 'description', 'additional_info', 'status'];
public static function labels(): array
{
return [
'title' => 'Название',
'type' => 'Тип',
'hours_count' => 'Количество часов',
'date_start' => 'Дата начала',
'date_end' => 'Дата окончания',
'place' => 'Место',
'event_format' => 'Формат',
'description' => 'Описание',
'additional_info' => 'Дополнительная информация',
'status' => 'Статус',
];
}
/**
* @return string[]
*/
public static function getStatus(): array
{
return [
self::DISABLE_STATUS => "Не активный",
self::ACTIVE_STATUS => "Активный",
];
}
public function contacts(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(EventContact::class);
}
/**
* @throws \Exception
*/
public function getDateStartFormatedAttribute(): string
{
$startDate = new DateTime($this->date_start);
return $startDate->format("d-m-Y");
}
/**
* @throws \Exception
*/
public function getDateStartFormatedToFormAttribute(): string
{
$startDate = new DateTime($this->date_start);
return $startDate->format("Y-m-d");
}
/**
* @throws \Exception
*/
public function getDateEndFormatedAttribute(): string
{
$endDate = new DateTime($this->date_end);
return $endDate->format("d-m-Y");
}
/**
* @throws \Exception
*/
public function getDateEndFormatedToFormAttribute(): string
{
$endDate = new DateTime($this->date_end);
return $endDate->format("Y-m-d");
}
}