krgm.so-manager-dev.com/app/Models/Psection.php
ou.zaikou e1629913bd 初回コミット
Signed-off-by:  ou.zaikou<caihaoweng@gmail.com>
2025-08-21 23:09:40 +09:00

43 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;
class Psection extends Model
{
// テーブル名
protected $table = 'psection';
// 主キー
protected $primaryKey = 'psection_id';
// 主キーが自動増分でない場合はfalseに設定
public $incrementing = false;
// タイムスタンプ管理しない場合はfalseに設定
public $timestamps = false;
// 一括代入可能なカラム
protected $fillable = [
'psection_id', // 車種区分ID
'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');
}
}