115 lines
2.6 KiB
PHP
115 lines
2.6 KiB
PHP
<?php
|
||
|
||
namespace App\Legacy;
|
||
|
||
use Illuminate\Database\Eloquent\Model;
|
||
use Illuminate\Support\Facades\Auth;
|
||
|
||
/**
|
||
* 旧システム利用者モデル(互換)
|
||
* - テーブル: user
|
||
* - 主キー: user_seq
|
||
* - 旧機能で参照されるメソッド/定数を保持
|
||
*/
|
||
class User extends Model
|
||
{
|
||
public const CREATED_AT = 'created_at';
|
||
public const UPDATED_AT = 'updated_at';
|
||
|
||
protected $table = 'user';
|
||
protected $primaryKey = 'user_seq';
|
||
|
||
protected $fillable = [
|
||
'user_seq',
|
||
'user_id',
|
||
'member_id',
|
||
'user_manual_regist_flag',
|
||
'user_mailing_flag',
|
||
'contract_number',
|
||
'user_tag_serial',
|
||
'user_tag_serial_64',
|
||
'qr_code',
|
||
'tag_qr_flag',
|
||
'user_aid',
|
||
'user_park_number',
|
||
'user_place_qrid',
|
||
'user_categoryid',
|
||
'user_name',
|
||
'user_phonetic',
|
||
'ward_residents',
|
||
'user_gender',
|
||
'user_birthdate',
|
||
'user_mobile',
|
||
'user_homephone',
|
||
'user_primemail',
|
||
'user_submail',
|
||
'user_regident_zip',
|
||
'user_regident_pre',
|
||
'user_regident_city',
|
||
'user_regident_add',
|
||
'user_relate_zip',
|
||
'user_relate_pre',
|
||
'user_relate_city',
|
||
'user_relate_add',
|
||
'user_workplace',
|
||
'user_school',
|
||
'user_graduate',
|
||
'user_reduction',
|
||
'user_idcard',
|
||
'user_idcard_chk_flag',
|
||
'user_chk_day',
|
||
'user_chk_opeid',
|
||
'user_tag_issue',
|
||
'issue_permission',
|
||
'user_quit_flag',
|
||
'user_quitday',
|
||
'user_remarks',
|
||
'user_age',
|
||
];
|
||
|
||
protected static function boot()
|
||
{
|
||
parent::boot();
|
||
static::creating(function (User $model) {
|
||
// 旧挙動:作成者オペレータIDを保存
|
||
if (Auth::check() && property_exists($model, 'ope_id')) {
|
||
$model->ope_id = Auth::user()->ope_id ?? null;
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 旧: ユーザーSEQで1件取得
|
||
*/
|
||
public static function getUserBySeq($seq)
|
||
{
|
||
return static::find($seq);
|
||
}
|
||
|
||
/**
|
||
* 旧: ユーザー区分(Usertype)
|
||
*/
|
||
public function getUserType()
|
||
{
|
||
return $this->belongsTo(Usertype::class, 'user_categoryid', 'user_categoryid')->first();
|
||
}
|
||
|
||
/**
|
||
* 旧: 氏名セレクト用
|
||
*/
|
||
public static function getList()
|
||
{
|
||
return static::pluck('user_name', 'user_seq');
|
||
}
|
||
|
||
/**
|
||
* 旧: 電話番号取得
|
||
*/
|
||
public static function getUserPhone()
|
||
{
|
||
return static::select('user_seq', 'user_name', 'user_mobile', 'user_homephone')->get();
|
||
}
|
||
}
|
||
|
||
|