krgm.so-manager-dev.com/app/Models/Pplace.php
SongSong cf95babf8e
All checks were successful
Deploy previews (main_*) / preview (push) Successful in 10s
SWA-63駐輪車室マスタ作成
2025-08-21 20:50:27 +09:00

81 lines
1.7 KiB
PHP
Raw Permalink 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\Support\Facades\Auth;
use App\Utils;
use Illuminate\Database\Eloquent\Model;
class Pplace extends Model
{
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
const PERPAGE = 50;
protected $table = 'pplace';
protected $primaryKey = 'pplace_id';
protected $fillable = [
'pplace_number',
'pplace_remarks',
'operator_id'
];
/*
public static function boot()
{
parent::boot();
self::creating(function (Pplace $model) {
if (Auth::check()) {
$model->operator_id = Auth::user()->ope_id;
}
});
}
*
/**
* 一覧検索・ソート処理
*/
public static function search($inputs)
{
$list = self::query();
if ($inputs['isMethodPost'] ?? false) {
// ここで条件検索処理を追加可能(例: $list->where(...);
}
// 並び順
if (!empty($inputs['sort'])) {
$list->orderBy($inputs['sort'], $inputs['sort_type'] ?? 'asc');
}
if ($inputs['isExport'] ?? false) {
return $list->get();
} else {
return $list->paginate(Utils::item_per_page);
}
}
/**
* 主キーで取得
*/
public static function getByPk($pk)
{
return self::find($pk);
}
/**
* 主キー配列で一括削除
*/
public static function deleteByPk($arr)
{
return self::whereIn('pplace_id', $arr)->delete();
}
/**
* 選択リスト取得用(フォーム等)
*/
public static function getList()
{
return self::pluck('pplace_number', 'pplace_id');
}
}