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

declare(strict_types=1);

namespace 
AppModels;

use 
IlluminateDatabaseEloquentModel;
use 
IlluminateDatabaseEloquentRelationsBelongsTo;
use 
IlluminateSupportCollection;

/**
 * Class User
 *
 * @property int    $id
 * @property int    $user_id
 * @property int    $field_id
 * @property string $value
 * @property-read Collection<UserField> $field
 */
class UserData extends Model
{
    
/**
     * Indicates if the model should be timestamped.
     */
    
public $timestamps false;

    
/**
     * The attributes that are mass assignable.
     */
    
protected $fillable = [
        
'value',
        
'field_id',
    ];

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

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

    
/**
     * Return field
     */
    
public function field(): BelongsTo
    
{
        return 
$this->belongsTo(UserField::class, 'field_id')->withDefault();
    }
}
Онлайн: 1
Реклама