Skip to content

Commit 6ccf680

Browse files
committed
feat: implement sorting functionality with new SortingScope and HasSortingScopeTrait
1 parent 629f639 commit 6ccf680

File tree

4 files changed

+4
-42
lines changed

4 files changed

+4
-42
lines changed

app/Http/Scopes/BaseSearchScope.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

contexts/Authorization/Infrastructure/Records/RoleRecord.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
use App\Exceptions\SysException;
88
use App\Http\Models\BaseModel;
9-
use App\Http\Traits\HasSortingScopeTrait;
109
use Contexts\Authorization\Domain\Role\Models\Role;
1110
use Contexts\Authorization\Domain\Role\Models\RoleId;
1211
use Contexts\Authorization\Domain\Role\Models\RoleStatus;
1312
use Contexts\Authorization\Infrastructure\RecordFactories\RoleRecordFactory;
13+
use Contexts\Shared\Infrastructure\Traits\HasSortingScopeTrait;
1414
use Illuminate\Database\Eloquent\Builder;
1515
use Illuminate\Database\Eloquent\Factories\Factory;
1616
use Illuminate\Support\Carbon;

app/Http/Scopes/SortingScope.php renamed to contexts/Shared/Infrastructure/Scopes/SortingScope.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,12 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Http\Scopes;
5+
namespace Contexts\Shared\Infrastructure\Scopes;
66

77
use Illuminate\Contracts\Database\Eloquent\Builder;
88

99
class SortingScope
1010
{
11-
/**
12-
* @param array{
13-
* sorting: array<int, array{
14-
* field: string,
15-
* direction?: string
16-
* }>
17-
* } $params
18-
* @return void
19-
*/
2011
public static function apply(Builder $query, array $sorting = [])
2112
{
2213
if (empty($sorting)) {

app/Http/Traits/HasSortingScopeTrait.php renamed to contexts/Shared/Infrastructure/Traits/HasSortingScopeTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Http\Traits;
5+
namespace Contexts\Shared\Infrastructure\Traits;
66

7-
use App\Http\Scopes\SortingScope;
7+
use Contexts\Shared\Infrastructure\Scopes\SortingScope;
88
use Illuminate\Database\Eloquent\Builder;
99

1010
trait HasSortingScopeTrait

0 commit comments

Comments
 (0)