/** * Checks if the pages data is valid. * * @return bool */ public function validates($data = null) { parent::validates($data); // Make sure the slug isnt in use.. $checkSlug = static::select('id')->where('id != ?', $this->_isNew ? 0 : $this->id)->andWhere('slug = ?', $this->slug)->andWhere('project_id = ?', $this->project_id); if ($checkSlug->rowCount()) { $this->addError('slug', 'unique', ['field' => 'slug', 'error' => "already_in_use"]); } return count($this->_errors) == 0; }