merge([ 'date_start' => Carbon::parse("$this->date_start_date $this->date_start_time:00")->toDateTimeString(), 'date_end' => Carbon::parse("$this->date_end_date $this->date_end_time:00")->toDateTimeString(), ]); // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch } catch (InvalidFormatException $e) { // On fait rien } $this->merge([ 'link_new_tab' => $this->link_new_tab ? true : false ]); if (auth()->check()) { return true; } return false; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'title' => 'required|max:255', 'text' => 'sometimes|max:255', 'picture' => 'sometimes|image|mimes:jpeg,png,jpg|max:2048|dimensions:width=1920,height=812', 'link_label' => 'sometimes|max:255', 'link' => 'sometimes|max:255', 'link_new_tab' => 'required|boolean', 'slider_id' => 'required|exists:sliders,id', 'date_start' => [ 'nullable', 'date_format:Y-m-d H:i:s', 'before:' . Carbon::now()->parse('2037-12-31'), 'after:' . Carbon::now()->format('Y-m-d') ], 'date_end' => [ 'nullable', 'date_format:Y-m-d H:i:s', 'after:date_start_date', 'before:' . Carbon::now()->parse('2037-12-31') ], ]; } }