118 lines
3.3 KiB
PHP
118 lines
3.3 KiB
PHP
<?php
|
||
|
||
namespace kernel\app_modules\gestalt_profile\models;
|
||
|
||
use Illuminate\Database\Eloquent\Model;
|
||
use kernel\app_modules\gestalt_profile_relationship\models\GestaltProfileRelationship;
|
||
|
||
// Добавить @property
|
||
/**
|
||
* @property int $id
|
||
* @property int $status
|
||
* @property int $show_on_main
|
||
* @property int $user_id
|
||
* @property string $fio
|
||
* @property string $phone
|
||
* @property string $email
|
||
* @property string $city
|
||
* @property string $photo
|
||
* @property string $community_status
|
||
* @property string $specialization
|
||
* @property string $description_of_professional_activity
|
||
* @property string $past_events
|
||
* @property string $upcoming_events
|
||
* @property string $under_curation_events
|
||
* @property array $communityStatusArr
|
||
* @property array $specializationArr
|
||
*/
|
||
class Gestalt_profile extends Model
|
||
{
|
||
const DISABLE_STATUS = 0;
|
||
const ACTIVE_STATUS = 1;
|
||
|
||
const DONT_SHOW_ON_MAIN = 0;
|
||
|
||
const SHOW_ON_MAIN = 1;
|
||
|
||
protected $table = 'gestalt_profile';
|
||
|
||
protected $fillable = [
|
||
'user_id',
|
||
'fio',
|
||
'phone',
|
||
'email',
|
||
'city',
|
||
'photo',
|
||
'community_status',
|
||
'specialization',
|
||
'description_of_professional_activity',
|
||
'past_events',
|
||
'upcoming_events',
|
||
'under_curation_events',
|
||
'status',
|
||
'show_on_main',
|
||
];
|
||
|
||
public static function labels(): array
|
||
{
|
||
return [
|
||
'user_id' => 'Пользователь',
|
||
'fio' => 'ФИО',
|
||
'phone' => 'Телефон',
|
||
'email' => 'Почта',
|
||
'city' => 'Город',
|
||
'photo' => 'Фото',
|
||
'community_status' => 'Статус в сообществе',
|
||
'specialization' => 'Специализация',
|
||
'description_of_professional_activity' => 'Описание профессиональной деятельности',
|
||
'past_events' => 'Прошедшие мероприятия',
|
||
'upcoming_events' => 'Будущие мероприятия',
|
||
'under_curation_events' => 'Под руководством специалиста',
|
||
'status' => 'Статус',
|
||
'show_on_main' => 'Показать на главной',
|
||
];
|
||
}
|
||
|
||
/**
|
||
* @return string[]
|
||
*/
|
||
public static function getStatus(): array
|
||
{
|
||
return [
|
||
self::DISABLE_STATUS => "Не активный",
|
||
self::ACTIVE_STATUS => "Активный",
|
||
];
|
||
}
|
||
|
||
/**
|
||
* @return string[]
|
||
*/
|
||
public static function getShowOnMain(): array
|
||
{
|
||
return [
|
||
self::DONT_SHOW_ON_MAIN => "Не показывать",
|
||
self::SHOW_ON_MAIN => "Показывать",
|
||
];
|
||
}
|
||
|
||
public function relationships(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||
{
|
||
return $this->hasMany(GestaltProfileRelationship::class, 'gestalt_profile_id');
|
||
}
|
||
|
||
public function getCommunityStatusArrAttribute(): array
|
||
{
|
||
return array_filter(explode(", ", $this->community_status));
|
||
}
|
||
|
||
public function getSpecializationArrAttribute(): array
|
||
{
|
||
return array_filter(explode(", ", $this->specialization));
|
||
}
|
||
|
||
public static function getCountProfiles()
|
||
{
|
||
return self::count();
|
||
}
|
||
|
||
} |