Migrated endpoints from user to member; Renamed membership to member

This commit is contained in:
Constantin Graf
2024-05-13 19:50:50 +02:00
parent ba335b4f05
commit b2365e2778
64 changed files with 853 additions and 456 deletions

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Http\Requests\V1\TimeEntry;
use App\Models\Member;
use App\Models\Organization;
use App\Models\Project;
use App\Models\Tag;
@@ -28,14 +29,38 @@ class TimeEntryAggregateRequest extends FormRequest
public function rules(): array
{
return [
'group_1' => [
'group' => [
'nullable',
'required_with:group_2',
'in:day,week,month,year,user,project,task,client,billable',
],
'group_2' => [
'sub_group' => [
'nullable',
'in:day,week,month,year,user,project,task,client,billable',
],
// Filter by member ID
'member_id' => [
'string',
'uuid',
new ExistsEloquent(Member::class, null, function (Builder $builder): Builder {
/** @var Builder<Member> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
],
// Filter by multiple member IDs, member IDs are OR combined, but AND combined with the member_id parameter
'member_ids' => [
'array',
'min:1',
],
'member_ids.*' => [
'string',
'uuid',
new ExistsEloquent(Member::class, null, function (Builder $builder): Builder {
/** @var Builder<Member> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
],
// Filter by user ID
'user_id' => [

View File

@@ -4,11 +4,11 @@ declare(strict_types=1);
namespace App\Http\Requests\V1\TimeEntry;
use App\Models\Member;
use App\Models\Organization;
use App\Models\Project;
use App\Models\Tag;
use App\Models\Task;
use App\Models\User;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Foundation\Http\FormRequest;
@@ -28,13 +28,26 @@ class TimeEntryIndexRequest extends FormRequest
public function rules(): array
{
return [
// Filter by user ID
'user_id' => [
// Filter by member ID
'member_id' => [
'string',
'uuid',
new ExistsEloquent(User::class, null, function (Builder $builder): Builder {
/** @var Builder<User> $builder */
return $builder->belongsToOrganization($this->organization);
new ExistsEloquent(Member::class, null, function (Builder $builder): Builder {
/** @var Builder<Member> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
],
// Filter by multiple member IDs, member IDs are OR combined, but AND combined with the member_id parameter
'member_ids' => [
'array',
'min:1',
],
'member_ids.*' => [
'string',
'uuid',
new ExistsEloquent(Member::class, null, function (Builder $builder): Builder {
/** @var Builder<Member> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
],
// Filter by project IDs, project IDs are OR combined

View File

@@ -4,11 +4,11 @@ declare(strict_types=1);
namespace App\Http\Requests\V1\TimeEntry;
use App\Models\Member;
use App\Models\Organization;
use App\Models\Project;
use App\Models\Tag;
use App\Models\Task;
use App\Models\User;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Foundation\Http\FormRequest;
@@ -27,14 +27,14 @@ class TimeEntryStoreRequest extends FormRequest
public function rules(): array
{
return [
// ID of the user that the time entry should belong to
'user_id' => [
// ID of the organization member that the time entry should belong to
'member_id' => [
'required',
'string',
'uuid',
new ExistsEloquent(User::class, null, function (Builder $builder): Builder {
/** @var Builder<User> $builder */
return $builder->belongsToOrganization($this->organization);
new ExistsEloquent(Member::class, null, function (Builder $builder): Builder {
/** @var Builder<Member> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
],
'project_id' => [

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Http\Requests\V1\TimeEntry;
use App\Models\Member;
use App\Models\Organization;
use App\Models\Project;
use App\Models\Tag;
@@ -26,6 +27,16 @@ class TimeEntryUpdateRequest extends FormRequest
public function rules(): array
{
return [
// ID of the organization member that the time entry should belong to
'member_id' => [
'string',
'uuid',
new ExistsEloquent(Member::class, null, function (Builder $builder): Builder {
/** @var Builder<Member> $builder */
return $builder->whereBelongsTo($this->organization, 'organization');
}),
],
// ID of the project that the time entry should belong to
'project_id' => [
'nullable',
'string',