Update a record with a single field

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 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)

    
asked by anonymous 30.08.2016 / 19:34

1 answer

0

I think your problem is different. The error Parse error: syntax error, unexpected T_VARIABLE means that PHP was not expecting the definition of a variable at any given time.

Check out this answer here for more information on that particular error.

    
30.08.2016 / 21:56