public function run() { if (BonusStatus::all()->count() > 0) { return; } // StatusSeed $active = new BonusStatus(); $active->name = 'Active'; $active->save(); $cancelled = new BonusStatus(); $cancelled->name = 'Cancelled'; $cancelled->save(); }
public function run() { $active_id = BonusStatus::Active()->id; $bonusModel = config('bonus.bonus_model'); foreach ($bonusModel::all() as $bonus) { $bonus->bonus_status_id = $bonus->bonus_status_id ? $bonus->bonus_status_id : $active_id; $bonus->save(); } }
public function cancelBonusAndChildBonuses() { $this->canceled_at = new Carbon(); $this->bonus_status_id = BonusStatus::Cancelled()->id; $this->save(); foreach ($this->childBonuses as $child) { $child->canceled_at = new Carbon(); $child->bonus_status_id = BonusStatus::Cancelled()->id; $child->save(); } }
public function activeBonuses() { return $this->bonuses()->getQuery()->where('bonus_status_id', '=', BonusStatus::Active()->id); }