67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class UserInformationHistory extends Model
|
|
{
|
|
/**
|
|
* テーブル名
|
|
*/
|
|
protected $table = 'user_information_history';
|
|
|
|
/**
|
|
* 主キー
|
|
*/
|
|
protected $primaryKey = 'user_information_history_id';
|
|
|
|
/**
|
|
* タイムスタンプ使用
|
|
*/
|
|
public $timestamps = true;
|
|
|
|
/**
|
|
* 一括代入可能なカラム
|
|
*/
|
|
protected $fillable = [
|
|
'user_id',
|
|
'entry_date',
|
|
'user_information_history',
|
|
];
|
|
|
|
/**
|
|
* キャスト定義
|
|
*/
|
|
protected $casts = [
|
|
'user_information_history_id' => 'integer',
|
|
'user_id' => 'integer',
|
|
'entry_date' => 'date:Y-m-d',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* ユーザーとの関連
|
|
*/
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id', 'user_id');
|
|
}
|
|
|
|
/**
|
|
* APIレスポンス用の配列形式に変換
|
|
*/
|
|
public function toApiArray(): array
|
|
{
|
|
return [
|
|
'user_information_history_id' => $this->user_information_history_id,
|
|
'user_id' => $this->user_id,
|
|
'entry_date' => $this->entry_date?->format('Y-m-d'),
|
|
'user_information_history' => $this->user_information_history,
|
|
'created_at' => $this->created_at?->toIso8601String(),
|
|
'updated_at' => $this->updated_at?->toIso8601String(),
|
|
];
|
|
}
|
|
}
|