34 lines
810 B
PHP
34 lines
810 B
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Back;
|
|
|
|
use App\Traits\Requests\Api\HasLaravelFailedValidation;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class ModelAccessRequest extends FormRequest
|
|
{
|
|
use HasLaravelFailedValidation;
|
|
|
|
/**
|
|
* 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",
|
|
];
|
|
}
|
|
}
|