Exemplo n.º 1
0
 /**
  * Validates the object properties.
  * Throws a ValidationException in case of an error.
  */
 protected function validate()
 {
     $pages = Page::listInTheme($this->theme, true);
     Validator::extend('uniqueUrl', function ($attribute, $value, $parameters) use($pages) {
         $value = trim(strtolower($value));
         foreach ($pages as $existingPage) {
             if ($existingPage->getBaseFileName() !== $this->getBaseFileName() && strtolower($existingPage->getViewBag()->property('url')) == $value) {
                 return false;
             }
         }
         return true;
     });
     parent::validate();
 }