ldc-dam/app/Http/Requests/Bo/Ajax/CheckRefKeyRequest.php

44 lines
868 B
PHP
Raw Normal View History

<?php
namespace App\Http\Requests\Bo\Ajax;
use App\Models\Media;
use Illuminate\Foundation\Http\FormRequest;
class CheckRefKeyRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return \auth()->check() and $this->ajax();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->merge([
'media' => Media::where('id', $this->media_id)->first()
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'media_id' => 'required|exists:media,id,deleted_at,NULL'
];
}
}