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 unique, but when I do an update it says that slug already exists, in> slug of the record I'm 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 did not work:
ValidatorInterface::RULE_UPDATE => [
'slug' => 'required|unique:landings,slug,'.$landing->id,
],
FatalErrorException in LandingValidator.php line 25:
syntax error, unexpected '$ landing' (T_VARIABLE)