cms/app/Http/Requests/Admin/Posts/UpdatePostRequest.php

32 lines
754 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Http\Requests\Admin\Posts;
use Illuminate\Foundation\Http\FormRequest;
class UpdatePostRequest extends BasePostRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize(): bool
{
return $this->user() && $this->user()->hasPermission('edit-posts');
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$post = $this->route('post');
$id = $post instanceof \App\Models\Post ? $post->id : $post;
return $this->baseRules($id);
}
}