How to solve the problem with the validator is unique when updating a post?

Already was asked a similar question, but the answer did not hit me, and I think that the solution is not quite correct.

When you update a post if the title has changed, for example, the validator will issue an error: "Is already in use".

How can I solve this problem ?

Thank you!
June 5th 19 at 22:01
3 answers
June 5th 19 at 22:03
Solution
You can make custom handlebars. It make checks of the header.
Documentation - https://laravel.ru/docs/v5/validation#собственные

Total in the controller code will be nice and may be repeatedly reused.
June 5th 19 at 22:05
Solution
$someid=123;

'somefield' => [
 Rule::unique('sometable', 'somefield')->where(function ($query) use ($someid) {
 $query->where('id', '<>', $someid);
})
 ],


well, or https://laravel.com/docs/5.6/validation#custom-val...
Thank You, Alexander! - terry.Hagenes33 commented on June 5th 19 at 22:08
Sir, let indiscreet question — why are you helping this evil ignorschik documentation? After all, zero sense — he was not studying, and not studying. - Penelope91 commented on June 5th 19 at 22:11
You're damn right! Support! - terry.Hagenes33 commented on June 5th 19 at 22:14
waiting for them to enter the ignore list, automatic answer, then I have pity to erase xD - bailee_Stant commented on June 5th 19 at 22:17
well look below gave a link to the Doc where it is written the same as you. But even that is a citizen does not consider it a response — there is a must read. That's just beyond evil... - Penelope91 commented on June 5th 19 at 22:20
June 5th 19 at 22:07
Solution

Find more questions by tags Laravel