public function allActiveAndClaimed() { Paginator::setPageName('tasks_page'); $tasks = Task::unClaimed()->active()->paginate(Config::get('config.active_task_per_page', 16)); Paginator::setPageName('claimed_tasks_page'); $claimed_tasks = Task::claimed()->paginate(Config::get('config.unclaimed_task_per_page', 8)); return array('tasks' => $tasks, 'claimed_tasks' => $claimed_tasks); }
public function fire() { $options = $this->option(); $debug = is_true($options['debug']); if ($options['job'] == 'expired_tasks') { $this->info("Looking for expired tasks..."); $tasks = Task::unClaimed()->get()->filter(function ($task) { if ($task->notifications()->forEvent(Notification::NOTIFICATION_TASK_EXPIRED)->get()->count() == 0 && $task->isExpired()) { return $task; } }); foreach ($tasks as $task) { $ago = $task->date->diffForHumans(); $this->info("({$task->id}) {$task->title} Expired - {$ago}"); $n = $task->notifications()->forEvent(Notification::NOTIFICATION_TASK_EXPIRED)->get()->count(); if ($n == 0) { Notification::fire($task, Notification::NOTIFICATION_TASK_EXPIRED); $this->info("\tNotification Created " . $task->id); } else { $this->info("*** Notification not sent"); } } if ($tasks->count() == 0) { $this->info("*** No expired tasks found ***"); } return; } if ($options['job'] == 'notifications') { // first get all users that want to receive notifications $users = User::where('notifications', '=', 1)->get(); // get all notifications that have not been sent out $notifications = Notification::whereNull('sent_at')->get(); if ($notifications->count() == 0) { $this->info("*** No New Notification ***"); return; } $results = []; foreach ($notifications as $notice) { $this->info("Notification: " . $notice->getTitle() . " : " . $notice->event); $status = $notice->send($debug); $this->info("\t status: " . strbool($status)); } return $results; } }