mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-05 07:20:58 +08:00
19 lines
393 B
PHP
19 lines
393 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Repositories;
|
||
|
|
|
||
|
|
use Illuminate\Support\Str;
|
||
|
|
|
||
|
|
class BaseRepository
|
||
|
|
{
|
||
|
|
protected function getSortFieldAndType(array $params)
|
||
|
|
{
|
||
|
|
$field = $params['sort_field'] ?? 'id';
|
||
|
|
$type = 'desc';
|
||
|
|
if (!empty($params['sort_type']) && Str::startsWith($params['sort_type'], 'asc')) {
|
||
|
|
$type = 'asc';
|
||
|
|
}
|
||
|
|
return [$field, $type];
|
||
|
|
}
|
||
|
|
}
|