Validate fee_id
This commit is contained in:
parent
d7591a7055
commit
7d5d59dc0c
|
@ -5,6 +5,9 @@ namespace App\Member;
|
|||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use App\Group;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Activity;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class MemberRequest extends FormRequest
|
||||
{
|
||||
|
@ -28,6 +31,15 @@ class MemberRequest extends FormRequest
|
|||
return [
|
||||
'first_activity_id' => Rule::requiredIf(fn() => $this->method() == 'POST'),
|
||||
'first_subactivity_id' => Rule::requiredIf(fn() => $this->method() == 'POST'),
|
||||
'fee_id' => Rule::requiredIf(function() {
|
||||
if ($this->method() != 'POST') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->input('first_activity_id')) { return true; }
|
||||
|
||||
return Str::contains(Activity::findOrFail($this->input('first_activity_id'))->name, '€');
|
||||
}),
|
||||
'firstname' => 'required',
|
||||
'lastname' => 'required',
|
||||
'address' => 'required',
|
||||
|
@ -51,6 +63,13 @@ class MemberRequest extends FormRequest
|
|||
}
|
||||
|
||||
public function persistUpdate(Member $member) {
|
||||
$member->update($this->input());
|
||||
$member->update(Arr::except($this->input(), ['first_activity_id', 'first_subactivity_id']));
|
||||
|
||||
if($this->input('has_nami') && $member->nami_id === null) {
|
||||
CreateJob::dispatch($member, auth()->user());
|
||||
}
|
||||
if($this->input('has_nami') && $member->nami_id !== null) {
|
||||
UpdateJob::dispatch($member, auth()->user());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue