mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-06-06 20:37:32 +00:00
43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\V1\Member;
|
|
|
|
use App\Http\Requests\V1\BaseFormRequest;
|
|
use App\Models\Member;
|
|
use App\Models\Organization;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
|
|
|
/**
|
|
* @property Organization $organization
|
|
*/
|
|
class MemberMergeIntoRequest extends BaseFormRequest
|
|
{
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, array<string|ValidationRule|\Illuminate\Contracts\Validation\Rule>>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
// ID of the member to which the data should be transferred (destination)
|
|
'member_id' => [
|
|
'string',
|
|
ExistsEloquent::make(Member::class, null, function (Builder $builder): Builder {
|
|
/** @var Builder<Member> $builder */
|
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
|
})->uuid(),
|
|
],
|
|
];
|
|
}
|
|
|
|
public function getMemberId(): string
|
|
{
|
|
return (string) $this->input('member_id');
|
|
}
|
|
}
|