66 lines
1.5 KiB
PHP
66 lines
1.5 KiB
PHP
<?php
|
|
|
|
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';
|
|
protected $primaryKey = 'user_categoryid';
|
|
|
|
protected $fillable = [
|
|
'print_name',
|
|
'usertype_money',
|
|
'usertype_remarks'
|
|
];
|
|
|
|
public static function boot()
|
|
{
|
|
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');
|
|
}
|
|
|
|
} |