finished api no auth
This commit is contained in:
40
laravel/app/Http/Requests/CommentaireRequest.php
Normal file
40
laravel/app/Http/Requests/CommentaireRequest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Exceptions\HttpResponseException;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
|
||||
class CommentaireRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'COM_DATE' => ['required', 'date'],
|
||||
'COM_AUTEUR' => ['required', 'string', 'max:100'],
|
||||
'COM_CONTENU' => ['required', 'string', 'max:200'],
|
||||
'billet_id' => ['required', 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
public function failedValidation(Validator $validator){
|
||||
throw new HttpResponseException(response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Validation errors',
|
||||
'data' => $validator->errors()
|
||||
]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user