public function debug() { $task_user_rolls = User::all()->lists('user_roll'); $exported_fields = ["msg.msg_id", "msg.task_id", "users.user_name", "msg.created_at", "msg.msg_data"]; $saved_msg = Msg::join('users', 'users.user_id', '=', 'msg.user_id')->where('msg_id', '=', 1)->select($exported_fields)->first(); // $saved_msg = "Hi from pragyan. Life la eppdi pogudhu?"; $push_message = Push::jsonEncode('message', $saved_msg); Push::sendMany($task_user_rolls, $push_message); }
/** * [sendMany description] * @param [type] $rollnums [Make sure it is iterable. Else use notify] * @param [type] $message [json encoded message. use Push::jsonEncode] * @return [type] [description] */ public static function sendMany($rollnums = NULL, $message = NULL) { // If rollnum is not specified, return if ($rollnums == NULL) { return; } foreach ($rollnums as $rollnum) { Push::notify($rollnum, $message); } }
public function deleteTask(Request $request) { $user_roll = $request->input('user_roll'); $task_id = $request->input('task_id'); if (!CheckLevel::check(2, NULL, $user_roll)) { return JSONResponse::response(401); } $task = Task::where('task_id', '=', $task_id)->where('enabled', '=', true)->first(); if ($task == NULL) { return JSONResponse::response(400); } $task->enabled = false; $task->save(); // Push Notification Code starts here $task_user_rolls = Assigned::where('task_id', '=', $task_id)->leftJoin('users', 'assigned.user_id', '=', 'users.user_id')->lists('user_roll'); $push_message = Push::jsonEncode('taskdelete', $task); Push::sendMany($task_user_rolls, $push_message); // Push Notification Code ends here return JSONResponse::response(200, true); }