ldc-mesbr-app/app/Http/Requests/Customers/StoreRequest.php
Vincent BRIDIER 203922849c
fix: PHPCBF
2025-04-03 09:30:16 +02:00

46 lines
1.1 KiB
PHP

<?php
namespace App\Http\Requests\Customers;
use App\Http\Resources\StatusResource;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;
class StoreRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'hashcode' => 'string|required',
'email' => 'email|required',
'country' => 'string|required'
];
}
protected function failedValidation(Validator $validator)
{
if ($this->wantsJson()) {
throw new HttpResponseException(response()->json(new StatusResource([
'status' => 'KO',
'code' => 422,
'message' => $validator->errors()->messages()
]), 422));
}
}
}