Esempio n. 1
0
 /**
  * Validate pathway
  * @param string $path
  * @return bool
  * @throws SyntaxException
  */
 public function pathIsFree($path)
 {
     $owner = ContentCategory::getById($this->dependId);
     if ($owner === null || $owner === false) {
         throw new SyntaxException();
     }
     // build path with owner category
     $this->_pathNested = $owner->path;
     if (Str::length($this->_pathNested) > 0) {
         $path = $this->_pathNested . '/' . $path;
     }
     // make select for check
     $query = ContentCategory::where('path', '=', $path);
     if ($this->_new !== true) {
         // exclude current category from checking path's
         $query->where('id', '!=', $this->_record->id);
     }
     return $query->count() === 0;
 }
Esempio n. 2
0
 /**
  * Get category relation of this content id
  * @return \Apps\ActiveRecord\ContentCategory|null
  */
 public function getCategory()
 {
     return ContentCategory::getById($this->category_id);
 }