Exemplo n.º 1
0
 public function __construct(array $data = [], $isNew = true)
 {
     parent::__construct($data, $isNew);
     if (!$isNew) {
         $this->original_status = $this->status_id;
     }
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
0
 /**
  * Add password confirmation validation.
  */
 public function validate()
 {
     $parent = parent::validate();
     if (isset($this->password_confirmation) && $this->password_confirmation !== $this->password) {
         $this->addValidationError('password', 'confirm');
     }
     return $parent;
 }
Exemplo n.º 4
0
 /**
  * Custom save method.
  */
 public function save()
 {
     // Set completed date
     if ($this->status != 1 and $this->completed_at == null) {
         $this->is_locked = true;
         $this->completed_at = new DateTime();
         $this->isBeingCompleted = true;
     } elseif ($this->status == 1) {
         $this->is_locked = false;
         $this->completed_at = null;
     }
     if (parent::save()) {
         return true;
     }
     return false;
 }