2021-09-17 23:48:30 +02:00
|
|
|
<?php
|
|
|
|
|
2021-11-07 21:57:22 +01:00
|
|
|
namespace App\Api\v1\Requests;
|
2021-09-17 23:48:30 +02:00
|
|
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
2021-11-13 13:36:34 +01:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2023-02-23 16:40:53 +01:00
|
|
|
use Illuminate\Validation\Rule;
|
2021-09-17 23:48:30 +02:00
|
|
|
|
2021-09-21 22:44:25 +02:00
|
|
|
class GroupStoreRequest extends FormRequest
|
2021-09-17 23:48:30 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
2021-11-13 13:36:34 +01:00
|
|
|
return Auth::check();
|
2021-09-17 23:48:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
2023-02-23 16:40:53 +01:00
|
|
|
'name' => [
|
|
|
|
'required',
|
2023-12-01 18:26:56 +01:00
|
|
|
'regex:/^[A-zÀ-ú0-9\s\-_]+$/',
|
2023-02-23 16:40:53 +01:00
|
|
|
'max:32',
|
2023-02-25 21:12:10 +01:00
|
|
|
Rule::unique('groups')->where(fn ($query) => $query->where('user_id', $this->user()->id)),
|
|
|
|
],
|
2021-09-17 23:48:30 +02:00
|
|
|
];
|
|
|
|
}
|
2021-09-21 22:44:25 +02:00
|
|
|
}
|