user(); return [ 'action' => ['required', 'bail','string', new RestoreDisabledRule()], 'ids' => ['required', 'bail', 'array'], 'email_type' => 'sometimes|in:reminder1,reminder2,reminder3,reminder_endless,custom1,custom2,custom3,invoice,quote,credit,payment,payment_partial,statement,purchase_order', 'template' => 'sometimes|string', 'template_id' => 'sometimes|string', 'send_email' => 'sometimes|bool', 'subscription_id' => 'sometimes|string', ]; } public function prepareForValidation() { /** @var \App\Models\User $user */ $user = auth()->user(); if (\Illuminate\Support\Facades\Cache::has($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key)) { throw new DuplicatePaymentException('Action still processing, please wait. ', 429); } $delay = $this->input('action', 'delete') == 'delete' ? (ceil(count($this->input('ids', 2)))) : 1; \Illuminate\Support\Facades\Cache::put(($this->ip()."|".$this->input('action', 0)."|".$user->company()->company_key), true, $delay); } }