public static function afterPurchaseEnroll($items, $idUser) { $isAdmin = GroupController::adminCheck($idUser); foreach ($items as $key => $item) { $sale = Price::find($item->id); if (is_null($sale->length)) { $end_at = Null; } else { $date = strtotime("+" . $sale->length . " day"); $end_at = date('Y-m-d H:i:s', $date); } if (!$isAdmin) { self::enroll($item->course_id, $idUser, $end_at); } else { ManagerController::addToBin($item->id, $item->qty, $idUser, $end_at); } } }