user(); return $user != null && $user->tokenCan('update'); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { if ($this->method() == 'PUT') { return [ 'locationName' => ['required'], 'locationCountry' => ['required'], 'currentTemperature' => ['required'], 'weatherIcon' => ['required'], 'weatherDescription' => ['required'], 'windSpeed' => ['required'], 'localtimeEpoch' => ['required'], ]; } } protected function prepareForValidation() { $this->merge([ 'location_name' => $this->locationName, 'location_country' => $this->locationCountry, 'current_temperature' => $this->currentTemperature, 'weather_icon' => $this->weatherIcon, 'weather_description' => $this->weatherDescription, 'wind_speed' => $this->wind_speed, 'localtime_epoch' => $this->localtime_epoch ]); } }