public function getEmailtaskopened($id = false) { if (!$id) { return App::abort(404); } $task = Task::find($id); if (!$task) { return App::abort(404); } Taskemails::taskOpened($task); }
/** * Execute the console command. * * @return void */ public function fire() { // list of users that created tasks $users = User::select([DB::RAW("DISTINCT users.id"), "users.firstname", "users.lastname", "users.email"])->join("tasks", "tasks.author_id", "=", "users.id")->whereNotNull("users.email")->whereRaw("tasks.deadline_at < NOW()")->take(100)->get(); foreach ($users as $user) { $missedTasks = Task::select(["tasks.id", "tasks.name", "tasks.deadline_at"])->where("tasks.author_id", $user->id)->whereRaw("tasks.deadline_at < NOW()")->orderBy("tasks.deadline_at")->take(100)->get(); if (count($missedTasks) == 0) { continue; } Taskemails::reportMissedTasks($user, $missedTasks); } }
public function postSavereassignment() { if (!Request::ajax()) { return App::abort(404); } $fields = ["user" => Input::get("user"), "id" => Input::get("id")]; $rules = ["user" => "required|numeric|exists:users,id", "id" => "required|numeric|exists:tasks,id"]; $customMessages = ["user.required" => "Вы не выбрали сотрудника"]; $validator = Validator::make($fields, $rules, $customMessages); if ($validator->fails()) { $error = ""; foreach (array_keys($fields) as $k) { $message = $validator->messages()->first($k); if ($message) { $error .= $message; } } return Response::json(["error" => $error]); } $task = Task::find(Input::get("id")); if (!$task) { return App::abort(404); } $task->deadline_at = $this->makeDeadlineDate(); $task->save(); $assign = new Taskassign(); $assign->task_id = Input::get("id"); $assign->user_from_id = $this->userdata->id; $assign->user_to_id = Input::get("user"); $assign->save(); Taskemails::taskAssigned($assign); return Response::json(["error" => ""]); }