I have request for updating page. When adding new page request is like:
'title'=>'required|max:70|unique:pages',
but when I'm updating page title must be unique but need to check all other titles except one already entered. I searched Google for all possible solutions but nothing works.
I tried:
'title'=>"required|max:70|unique:pages, title,{$this->id}",
'title'=>'required|max:70|unique:pages, title,'.$this->id,
'title'=>'required|max:70|unique:pages, title,'.$this->input('id'),
rule is inside rules method
public function rules()
{
return [
'title'=>'required|max:70|unique:pages, title,'.$this->id,
...
]
I'm getting this error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column ' title' in 'where clause' (SQL: select count(*) as aggregate from `pages` where ` title` = test and `id` <> )
In my mysql I have id (lowercase) column that is primary key and title column (also lowercase).