From 1120bdf70e1ef34851fbaf106a728c6af9f9bbb6 Mon Sep 17 00:00:00 2001 From: gitadmin Date: Sat, 23 Aug 2025 00:16:18 +0900 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20app/Models/Usertype.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Usertype.php | 60 ++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/app/Models/Usertype.php b/app/Models/Usertype.php index 4f50f72..ac73bd2 100644 --- a/app/Models/Usertype.php +++ b/app/Models/Usertype.php @@ -3,22 +3,64 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Auth; class Usertype extends Model { + const CREATED_AT = 'created_at'; + const UPDATED_AT = 'updated_at'; + const PERPAGE = 50; + protected $table = 'usertype'; - // プライマリーキーはLaravelのデフォルト('id')を使用 - public $timestamps = true; + protected $primaryKey = 'user_categoryid'; protected $fillable = [ - // 実際のカラム名が不明のため、一旦空にする + 'print_name', + 'usertype_money', + 'usertype_remarks' ]; - /** - * ユーザータイプのリストを取得 - */ - public static function getList() + public static function boot() { - return self::all(); + parent::boot(); + self::creating(function (Usertype $model) { + $model->operator_id = Auth::user()->ope_id; + }); } -} + + public static function search($inputs) + { + $list = self::query(); + if ($inputs['isMethodPost']) { + + } + // Sort + if ($inputs['sort']) { + $list->orderBy($inputs['sort'], $inputs['sort_type']); + } + if ($inputs['isExport']){ + $list = $list->get(); + }else{ + $list = $list->paginate(Utils::item_per_page); + } + return $list; + } + + public static function getByPk($pk) + { + return self::find($pk); + } + + public static function deleteByPk($arr) + { + return self::whereIn('user_categoryid', $arr)->delete(); + } + + //TODO 利用者分類ID not found in database specs + + //TODO 利用者分類名 not found in database specs + public static function getList(){ + return self::pluck('print_name','user_categoryid'); + } + +} \ No newline at end of file