Пример #1
0
 /**
  * Overrides the automated table checks to handle the 'hash' column for faster searching
  *
  * @return $this|DataModel
  */
 public function check()
 {
     // Create a slug if there is a title and an empty slug
     if ($this->hasField('title') && $this->hasField('slug') && !$this->slug) {
         $this->slug = String::toSlug($this->title);
     }
     // Create the SHA-1 hash of the slug for faster searching (make sure the hash column is CHAR(64) to take
     // advantage of MySQL's optimised searching for fixed size CHAR columns)
     if ($this->hasField('hash') && $this->hasField('slug')) {
         $this->hash = sha1($this->slug);
     }
     // Reset cached values
     $this->resetTreeCache();
     // Run the parent checks
     parent::check();
     return $this;
 }