server/app/Model/AssetCategory.php

55 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $category_id
* @property string $category_name
* @property int $account_type
* @property int $belong_id
* @property int $pid
* @property string $type
* @property int $rank
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class AssetCategory extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'asset_category';
protected string $primaryKey = 'category_id';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['category_id' => 'integer', 'account_type' => 'integer', 'belong_id' => 'integer', 'pid' => 'integer', 'rank' => 'integer'];
public static function list(array $param)
{
$model = (new self());
if (isset($param['account_type']) && $param['account_type'] != '') {
$model = $model->where('account_type', $param['account_type']);
}
if (isset($param['belong_id']) && $param['belong_id'] != '') {
$model = $model->where('belong_id', $param['belong_id']);
}
if (isset($param['type']) && $param['type'] != '') {
$model = $model->where('type', $param['type']);
}
return $model
->select(["category_id", "category_name", "pid"])
->get();
}
}