krgm.so-manager-dev.com/app/Models/Pplace.php
kin.rinzen e3201a680e
All checks were successful
Deploy main / deploy (push) Successful in 24s
駐輪車室マスタの画面修正
2025-09-18 16:32:48 +09:00

85 lines
1.8 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\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($ids)
{
if (!is_array($ids)) {
$ids = [$ids];
}
return self::whereIn('pplace_id', $ids)->delete();
}
/**
* 選択リスト取得用(フォーム等)
*/
public static function getList()
{
return self::pluck('pplace_number', 'pplace_id');
}
}