更新 app/Models/Psection.php
This commit is contained in:
parent
a5f6cb737e
commit
11e4ce2841
@ -34,8 +34,11 @@ class Psection extends Model
|
||||
'psection_subject', // 車種区分名
|
||||
'operator_id', // オペレータID
|
||||
'created_at', // 作成日時
|
||||
'updated_at' // 更新日時
|
||||
'updated_at', // 更新日時
|
||||
'psection_id' // 車種区分ID
|
||||
];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* キャストする属性
|
||||
@ -48,6 +51,14 @@ class Psection extends Model
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime'
|
||||
];
|
||||
|
||||
|
||||
// 主キーが自動増分でない場合はfalseに設定
|
||||
public $incrementing = false;
|
||||
// タイムスタンプ管理しない場合はfalseに設定
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 売上集計との関連
|
||||
@ -103,4 +114,30 @@ class Psection extends Model
|
||||
$this->psection_subject
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 新規作成時にoperator_idを自動設定(operator_idカラムがある場合のみ)
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
self::creating(function (Psection $model) {
|
||||
// ログインしている場合のみセット
|
||||
if (\Auth::check()) {
|
||||
$model->operator_id = Auth::user()->ope_id;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 車種区分リストを取得(プルダウン用)
|
||||
public static function getList()
|
||||
{
|
||||
return self::orderBy('psection_id')->pluck('psection_subject', 'psection_id');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user