protected function beforeCreate() { if (empty($this->slug) || $this->slugExists($this->slug)) { $this->setError('Slug already exists'); } return parent::beforeCreate(); }
protected function beforeCreate() { if (empty($this->user)) { //Lets try to find a user with this customer id $user = (new \Users\Models\Users())->setCondition('stripe.customer.id', $this->customer)->getItem(); if (!empty($user->id)) { $this->set('user', array('id' => $user->id, 'name' => $user->fullName())); } } if ($this->type == 'expense') { $available = \Finances\Models\Funds::getAvailableFunds($this->project); if ($this->amount >= $available['amount']) { die('NOT ENOUGH FUNDS'); } } return parent::beforeCreate(); }