Files
nexusphp/app/Repositories/BaseRepository.php

23 lines
469 B
PHP
Raw Normal View History

2021-04-17 19:01:33 +08:00
<?php
namespace App\Repositories;
2021-06-01 23:33:28 +08:00
use Illuminate\Encryption\Encrypter;
2021-04-17 19:01:33 +08:00
use Illuminate\Support\Str;
class BaseRepository
{
2021-06-01 23:33:28 +08:00
private static $enctyper;
protected function getSortFieldAndType(array $params): array
2021-04-17 19:01:33 +08:00
{
$field = $params['sort_field'] ?? 'id';
$type = 'desc';
if (!empty($params['sort_type']) && Str::startsWith($params['sort_type'], 'asc')) {
$type = 'asc';
}
return [$field, $type];
}
2021-06-01 23:33:28 +08:00
2021-04-17 19:01:33 +08:00
}