/** * Store a newly created resource in storage. * * @return Response */ public function store() { $tracker_ids = Request::get('tracker_ids'); $tracker_id = explode(',', $tracker_ids); $usernameArray = []; $response = null; foreach ($tracker_id as $id) { if (trim($id) != 'null') { $username = null; if (is_numeric($id)) { $user = User::where('mobile', '=', $id)->get(array('username')); foreach ($user as $name) { $username = $name->username; array_push($usernameArray, $username); } } $validate = TrackAssign::where('user_id', '=', Request::get('user_id'))->where('tracker_id', '=', $username)->first(); if ($username != null) { if ($validate == null) { $assign = new TrackAssign(); $assign->user_id = Request::get('user_id'); $assign->tracker_id = $username; $assign->status = 1; $assign->save(); return $response = RestApi::trackNotification($username, Request::get('user_id')); } else { $validate->status = 1; $validate->save(); return $response = RestApi::trackNotification($username, Request::get('user_id')); } } } } //return $response; /*return Response::json(array( "status" => "OK", "users" => $usernameArray), 200);*/ }