Skip to content

Commit

Permalink
Merge branch 'main' of github.com:solidtime-io/solidtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Onatcer committed Apr 26, 2024
2 parents 09595b4 + c25276b commit d0bc2ed
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/V1/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function index(Organization $organization): ClientCollection
$clients = Client::query()
->whereBelongsTo($organization, 'organization')
->orderBy('created_at', 'desc')
->paginate();
->paginate(config('app.pagination_per_page_default'));

return new ClientCollection($clients);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/V1/InvitationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function index(Organization $organization, InvitationIndexRequest $reques
$this->checkPermission($organization, 'invitations:view');

$invitations = $organization->teamInvitations()
->paginate();
->paginate(config('app.pagination_per_page_default'));

return InvitationCollection::make($invitations);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/V1/MemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function index(Organization $organization, MemberIndexRequest $request):
$this->checkPermission($organization, 'members:view');

$members = $organization->users()
->paginate();
->paginate(config('app.pagination_per_page_default'));

return MemberCollection::make($members);
}
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Api/V1/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand Down Expand Up @@ -38,7 +39,7 @@ protected function checkPermission(Organization $organization, string $permissio
*
* @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');
Expand All @@ -52,7 +53,7 @@ public function index(Organization $organization): ProjectCollection
$projectsQuery->visibleByUser($user);
}

$projects = $projectsQuery->paginate();
$projects = $projectsQuery->paginate(config('app.pagination_per_page_default'));

return new ProjectCollection($projects);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/V1/ProjectMemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function index(Organization $organization, Project $project): ProjectMemb

$projectMembers = ProjectMember::query()
->whereBelongsTo($project, 'project')
->paginate();
->paginate(config('app.pagination_per_page_default'));

return new ProjectMemberCollection($projectMembers);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/V1/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function index(Organization $organization): TagCollection
$tags = Tag::query()
->whereBelongsTo($organization, 'organization')
->orderBy('created_at', 'desc')
->paginate();
->paginate(config('app.pagination_per_page_default'));

return new TagCollection($tags);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Api/V1/TaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function index(Organization $organization, TaskIndexRequest $request): Ta
});
}

$tasks = $query->paginate();
$tasks = $query->paginate(config('app.pagination_per_page_default'));

return new TaskCollection($tasks);
}
Expand Down
26 changes: 26 additions & 0 deletions app/Http/Requests/V1/Project/ProjectIndexRequest.php
Original file line number Diff line number Diff line change
@@ -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',
],
];
}
}
3 changes: 2 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@

'faker_locale' => 'en_US',

'pagination_per_page_default' => (int) env('PAGINATION_PER_PAGE_DEFAULT', 15),

/*
|--------------------------------------------------------------------------
| Encryption Key
Expand Down Expand Up @@ -191,5 +193,4 @@
'aliases' => Facade::defaultAliases()->merge([
// 'Example' => App\Facades\Example::class,
])->toArray(),

];

0 comments on commit d0bc2ed

Please sign in to comment.