is('api/*')) { return true; } return auth()->check(); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ 'name' => 'required|string|max:255', 'description' => 'nullable|string|max:255', 'completed_at' => 'nullable' ]; } public function validatedWithCompletedAt(): array { // Return safe data merged with completed_at to unix timestamp return array_merge( $this->validated(), [ // Now or null 'completed_at' => $this->completed_at ? Carbon::now()->timestamp : null, ] ); } protected function passedValidation(): void { // Replace or add completed_at to the request, value is time now in unix format if ($this->has('completed_at')) { $this->request->add(['completed_at' => Carbon::now()->timestamp]); } else { $this->request->add(['completed_at' => null]); } } }