2025-12-15 15:46:00 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Back;
|
|
|
|
|
|
2026-01-27 16:48:50 +01:00
|
|
|
use App\Traits\Requests\Api\HasLaravelFailedValidation;
|
2025-12-15 15:46:00 +01:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
|
|
class ModelAccessRequest extends FormRequest
|
|
|
|
|
{
|
2026-01-27 16:48:50 +01:00
|
|
|
use HasLaravelFailedValidation;
|
|
|
|
|
|
2025-12-15 15:46:00 +01:00
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return auth('backend')->check() and $this->ajax();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'modelName' => 'required|string|between:3,255|regex:/^[a-z]+(?:_[a-z]+)*$/',
|
|
|
|
|
'selectedEntry' => "required|numeric|exists:{$this->input('modelName')},id",
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|