use this code but not work!!!! this code show error in update page that this value is already exists.
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use App\Post;
class PostsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'title' => ['required','max:255', Rule::unique('posts')->ignore($this->route('id'))],
'slug' => ['required', Rule::unique('posts')->ignore($this->route('id'))],
'content' => 'required',
'type' => 'required|in:blog,download,page',
'status' => 'required',
];
}
}
please help me.