mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-06-15 13:32:43 +01:00
Added per page pagination config
This commit is contained in:
@@ -40,7 +40,7 @@ class ClientController extends Controller
|
||||
$clients = Client::query()
|
||||
->whereBelongsTo($organization, 'organization')
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate();
|
||||
->paginate(config('app.pagination_per_page_default'));
|
||||
|
||||
return new ClientCollection($clients);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class InvitationController extends Controller
|
||||
$this->checkPermission($organization, 'invitations:view');
|
||||
|
||||
$invitations = $organization->teamInvitations()
|
||||
->paginate();
|
||||
->paginate(config('app.pagination_per_page_default'));
|
||||
|
||||
return InvitationCollection::make($invitations);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class MemberController extends Controller
|
||||
$this->checkPermission($organization, 'members:view');
|
||||
|
||||
$members = $organization->users()
|
||||
->paginate();
|
||||
->paginate(config('app.pagination_per_page_default'));
|
||||
|
||||
return MemberCollection::make($members);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Exceptions\Api\EntityStillInUseApiException;
|
||||
use App\Http\Requests\V1\Project\ProjectIndexRequest;
|
||||
use App\Http\Requests\V1\Project\ProjectStoreRequest;
|
||||
use App\Http\Requests\V1\Project\ProjectUpdateRequest;
|
||||
use App\Http\Resources\V1\Project\ProjectCollection;
|
||||
@@ -38,7 +39,7 @@ class ProjectController extends Controller
|
||||
*
|
||||
* @operationId getProjects
|
||||
*/
|
||||
public function index(Organization $organization): ProjectCollection
|
||||
public function index(Organization $organization, ProjectIndexRequest $request): ProjectCollection
|
||||
{
|
||||
$this->checkPermission($organization, 'projects:view');
|
||||
$canViewAllProjects = $this->hasPermission($organization, 'projects:view:all');
|
||||
@@ -52,7 +53,7 @@ class ProjectController extends Controller
|
||||
$projectsQuery->visibleByUser($user);
|
||||
}
|
||||
|
||||
$projects = $projectsQuery->paginate();
|
||||
$projects = $projectsQuery->paginate(config('app.pagination_per_page_default'));
|
||||
|
||||
return new ProjectCollection($projects);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class ProjectMemberController extends Controller
|
||||
|
||||
$projectMembers = ProjectMember::query()
|
||||
->whereBelongsTo($project, 'project')
|
||||
->paginate();
|
||||
->paginate(config('app.pagination_per_page_default'));
|
||||
|
||||
return new ProjectMemberCollection($projectMembers);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class TagController extends Controller
|
||||
$tags = Tag::query()
|
||||
->whereBelongsTo($organization, 'organization')
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate();
|
||||
->paginate(config('app.pagination_per_page_default'));
|
||||
|
||||
return new TagCollection($tags);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class TaskController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
$tasks = $query->paginate();
|
||||
$tasks = $query->paginate(config('app.pagination_per_page_default'));
|
||||
|
||||
return new TaskCollection($tasks);
|
||||
}
|
||||
|
||||
26
app/Http/Requests/V1/Project/ProjectIndexRequest.php
Normal file
26
app/Http/Requests/V1/Project/ProjectIndexRequest.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\V1\Project;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ProjectIndexRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, array<string|ValidationRule>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'page' => [
|
||||
'integer',
|
||||
'min:1',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -115,6 +115,8 @@ return [
|
||||
|
||||
'faker_locale' => 'en_US',
|
||||
|
||||
'pagination_per_page_default' => (int) env('PAGINATION_PER_PAGE_DEFAULT', 15),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
@@ -191,5 +193,4 @@ return [
|
||||
'aliases' => Facade::defaultAliases()->merge([
|
||||
// 'Example' => App\Facades\Example::class,
|
||||
])->toArray(),
|
||||
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user