Files
wonderful-weather/app/Http/Requests/StoreCityRequest.php
foobar 27c1969aaa init
2022-08-21 21:39:06 +02:00

51 lines
1.3 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreCityRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
$user = $this->user();
return $user != null && $user->tokenCan('create');
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
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
]);
}
}