Files
nexusphp/app/Repositories/BaseRepository.php
2021-06-01 23:33:28 +08:00

23 lines
469 B
PHP

<?php
namespace App\Repositories;
use Illuminate\Encryption\Encrypter;
use Illuminate\Support\Str;
class BaseRepository
{
private static $enctyper;
protected function getSortFieldAndType(array $params): array
{
$field = $params['sort_field'] ?? 'id';
$type = 'desc';
if (!empty($params['sort_type']) && Str::startsWith($params['sort_type'], 'asc')) {
$type = 'asc';
}
return [$field, $type];
}
}