Вход Регистрация
Файл: app/Models/Notice.php
Строк: 31
<?php

declare(strict_types=1);

namespace 
AppModels;

use 
AppCastsHtmlCast;
use 
CarbonCarbonImmutable;
use 
IlluminateDatabaseEloquentModel;
use 
IlluminateDatabaseEloquentRelationsBelongsTo;

/**
 * Class Notice
 *
 * @property int             $id
 * @property string          $type
 * @property string          $name
 * @property string          $text
 * @property int             $user_id
 * @property int             $protect
 * @property CarbonImmutable $created_at
 * @property CarbonImmutable $updated_at
 */
class Notice extends Model
{
    
/**
     * The attributes that aren't mass assignable.
     */
    
protected $guarded = [];

    
/**
     * Get the attributes that should be cast.
     */
    
protected function casts(): array
    {
        return [
            
'user_id' => 'int',
            
'text'    => HtmlCast::class,
        ];
    }

    
/**
     * Возвращает связь пользователя
     */
    
public function user(): BelongsTo
    
{
        return 
$this->belongsTo(User::class, 'user_id')->withDefault();
    }
}
Онлайн: 1
Реклама