Files
MrleeAdmin/backend/plugin/produce/app/dao/TransitionLogDao.php
T

66 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace plugin\produce\app\dao;
use core\base\BaseDao;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use plugin\produce\app\model\TransitionLog;
class TransitionLogDao extends BaseDao
{
protected function setModel(): string
{
return TransitionLog::class;
}
protected function getKeywordFields(): array
{
return ['work_order_no', 'trigger_user', 'error_message', 'remark'];
}
public function selectList(
array $where,
string|array $field = '*',
int $page = 0,
int $limit = 0,
string $order = '',
array $with = [],
bool $search = false,
?array $withoutScopes = null
): ?Collection {
$with = array_unique(array_merge($with, ['step', 'transition', 'fromStatus', 'toStatus']));
$order = $order ?: 'created_at desc, id desc';
return parent::selectList($where, $field, $page, $limit, $order, $with, $search, $withoutScopes);
}
public function get($id, ?array $field = null, ?array $with = [], string $order = '', ?array $withoutScopes = null): ?Model
{
$with = array_unique(array_merge($with ?? [], ['step', 'transition', 'fromStatus', 'toStatus']));
return parent::get($id, $field, $with, $order, $withoutScopes);
}
public function handleSearch(array $where, bool $isPage = true): Builder
{
$query = parent::handleSearch($where, $isPage);
if (($where['step_id'] ?? '') !== '') {
$query->where('step_id', $where['step_id']);
}
if (($where['trigger_event'] ?? '') !== '') {
$query->where('trigger_event', $where['trigger_event']);
}
if (($where['is_success'] ?? '') !== '') {
$query->where('is_success', $where['is_success']);
}
return $query;
}
}