0
I’m using the L5-Repository in my project, but I’m having the following difficulty:
I have the code below to make the Slug is unique, but when I update it says Slug already exists, when in fact it is the Slug from the very record I am editing. How can I resolve this?
class LandingValidator extends LaravelValidator
{
protected $rules = [
ValidatorInterface::RULE_CREATE => [
'slug' => 'required|unique:landings,slug',
],
ValidatorInterface::RULE_UPDATE => [
'slug' => 'required|unique:landings,slug',
],
];
}
I tried this way, but it didn’t work:
ValidatorInterface::RULE_UPDATE => [
'slug' => 'required|unique:landings,slug,'.$landing->id,
],
Fatalerrorexception in Landingvalidator.php line 25:
syntax error, Unexpected '$Landing' (T_VARIABLE)