where('user_categoryid', $userCategoryId) ->first(); } /** * レコード保存時に operator_id を自動設定 */ public static function boot() { parent::boot(); self::saving(function (ReductionMaster $model) { if (!isset($model->operator_id) || $model->operator_id === null) { $model->operator_id = Auth::user()->ope_id ?? null; } }); } }