user */ $user = auth()->user(); return $user->isAdmin(); } public function rules() { return [ 'date_range' => 'bail|sometimes|string|in:last7_days,last30_days,last365_days,this_month,last_month,this_quarter,last_quarter,this_year,last_year,all_time,custom', 'start_date' => 'bail|sometimes|date', 'end_date' => 'bail|sometimes|date', ]; } public function prepareForValidation() { $input = $this->all(); if(isset($input['date_range'])) { $dates = $this->calculateStartAndEndDates($input); $input['start_date'] = $dates[0]; $input['end_date'] = $dates[1]; } if (! isset($input['start_date'])) { $input['start_date'] = now()->subDays(20)->format('Y-m-d'); } if (! isset($input['end_date'])) { $input['end_date'] = now()->format('Y-m-d'); } nlog($input); $this->replace($input); } }