public function deploy(Request $request) { $ids = $request->input('ids'); if (empty($ids)) { $gathers = Gather::select('id', 'title', 'category', 'description', 'telephone', 'address', 'road_address', 'latitude', 'longitude', 'deploy')->where([['deploy', '<>', true], ['delete', '<>', true]])->orderby('created_at', 'desc')->get(); } else { $where = explode(',', $ids); $gathers = Gather::select('id', 'title', 'category', 'description', 'telephone', 'address', 'road_address', 'latitude', 'longitude', 'deploy')->where([['deploy', '<>', true], ['delete', '<>', true]])->whereIn('id', $where)->orderby('created_at', 'desc')->get(); } $success = 0; foreach ($gathers as $item) { $friend = Friend::where('gather_id', $item->id)->first(); if (empty($friend)) { $friend = new Friend(); } // 업장정보 저장 $friend->type = $item->category; $friend->gather_id = $item->id; $friend->name = $item->title; $friend->latitude = $item->latitude; $friend->longitude = $item->longitude; $friend->address = $item->address; $friend->road_address = $item->road_address; $friend->tel = $item->telephone; $friend->description = $item->description; $friend->save(); // 수집자료 배포 상태 업데이트 $item->deploy = true; $item->save(); $success++; } // 배포 히스토리 저장 $deployHistory = new GatherDeployHistory(); $deployHistory->deploy_count = $success; $deployHistory->save(); return response()->json(['result' => 'success', 'count' => $gathers->count(), 'success' => $success]); }
/** * A function that will accept a friend ID and removed them from user friend list * * @return json array */ public function delete() { $my_id = Auth::id(); $my_friend = Input::get('id'); $friend = Friend::where('user_id', $my_id)->where('my_friend', $my_friend)->delete(); $data['status'] = 1; $data['friend'] = $friend; return $data; }
public function searchUsers($search) { if (Auth::check()) { $users = DB::table('user')->join('role', 'user.role_id', '=', 'role.id')->leftjoin('media', 'user.media_id', '=', 'media.id')->select('user.id', 'first_name', 'last_name', 'role.name AS role', 'media.name AS photo', 'email')->where('user.is_deleted', '=', '0')->where('user.is_enable', '=', '1')->where('user.id', '!=', Auth::user()->id)->where('user.first_name', 'like', '%' . $search . '%')->orWhere('user.last_name', 'like', '%' . $search . '%')->get(); if ($users) { foreach ($users as $key => $value) { $friend = Friend::where('user_id', Auth::user()->id)->where('related_user_id', $value->id)->first(); if ($friend) { $users[$key]->category = $friend->category->name; $users[$key]->status = $friend->status; } else { $users[$key]->category = null; $users[$key]->status = null; } } } return response()->json(["data" => $users, "result" => "success"], 200); } else { return response()->json(["result" => "error_access_deny"], 200); } }
public function showUserFriends($id) { if (Auth::check()) { $friends = DB::table('friend')->join('user', 'friend.related_user_id', '=', 'user.id')->leftjoin('media', 'user.media_id', '=', 'media.id')->select('user.id', 'first_name', 'last_name', 'media.name AS photo', 'email', 'friend.status AS status')->where('user_id', $id)->where('related_user_id', '!=', Auth::user()->id)->where('user.is_deleted', '0')->where('user.is_enable', '1')->where('friend.status', 'friend')->get(); if ($friends) { foreach ($friends as $key => $value) { $friend = Friend::where('user_id', Auth::user()->id)->where('related_user_id', $value->id)->where('status', 'friend')->first(); if (!$friend) { $friends[$key]->isMyFriend = 0; } else { $friends[$key]->isMyFriend = 1; } } } return response()->json(['result' => 'success', 'data' => $friends], 200); } return response()->json(['result' => 'error'], 200); }
public function data(Request $request) { $update_date = $request->input('update_date'); if (empty($update_date)) { $friends = Friend::all(); } else { $friends = Friend::where([['created_at', '>', $update_date], ['updated_at', '>', $update_date]])->get(); } return response()->json(['date' => $update_date, 'total' => $friends->count(), 'friends' => $friends], 200); }