File: /home/imensosw/www/mpl.imenso.co/app/Http/Requests/ArtistUpdateDetailsRequest.php
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ArtistUpdateDetailsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->input('artist_id') == $this->user()->id;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'city' => '',
'country' => '',
'year_founded' => '',
'artist_bio' => '',
'artist_name' => 'required',
'location' => 'required',
'lat' => 'required',
'genres' => 'required',
];
}
public function messages()
{
return [
'lat.required' => 'You must select a location',
'location.required' => 'You must select a location',
];
}
/**
* Configure the validator instance.
*
* @param \Illuminate\Validation\Validator $validator
* @return void
*/
public function withValidator($validator)
{
$validator->fails(function ($validator) {
$this->session()->flash('artist-edit-details-open', true);
return redirect()->back()->withErrors($validator);
});
}
}