/**
  * @param $string
  * @param null $id
  * @return mixed|string
  */
 protected function validateSlug($string, $id = null)
 {
     $slug = Str::slug(strtolower($string));
     // check if id is set
     if (is_null($id)) {
         $count = count(User::where('slug', 'LIKE', $slug . '%')->get());
         // return the slug
         return $count > 0 ? "{$slug}-{$count}" : $slug;
     }
     // there is an ID set, get user
     $user = $this->findById($id);
     // check if slug is the same with the user slug
     if ($user->slug == $slug) {
         return $user->slug;
     }
     return $slug;
 }
 public function validateDatabasePassword($attribute, $value, $parameters)
 {
     // get the user
     $result = User::where('id', '=', $parameters[0])->first();
     return Hash::check($value, $result->password);
 }