示例#1
0
 public function accept_request_follower()
 {
     $app = app();
     if (Request::has('token')) {
         $token = Request::input('token', '');
         $compare = GlobalLibrary::tokenExtractor($token);
         $users_checker = GlobalLibrary::CheckUsersToken($compare);
         if ($users_checker[0]) {
             $uname = $users_checker[1];
             $uid = $users_checker[2];
             $email = $users_checker[3];
             $followingid = Request::input('fol', '');
             $users = table_users_detail::where('users_id', '=', $followingid)->first();
             $jsonfollow = $users->users_json_following;
             //insert my id to his/her detail
             $datausersdetail = array('users_json_following' => $jsonfollow . ',' . $uid);
             $data = table_users_detail::find($followingid);
             $data->update($datausersdetail);
             //delete his/her request because it has accepted
             $follow_requesting = table_request_follow::where('users_id', '=', $followingid)->first();
             $request_following = $follow_requesting->json_request_follow;
             $arrayfollow = explode(',', $request_following);
             if (($key = array_search($uid, $arrayfollow)) !== false) {
                 unset($arrayfollow[$key]);
             }
             $new_json_request_follow = implode(',', $arrayfollow);
             //update his/her request
             $new_json = array('json_request_follow' => $new_json_request_follow);
             $data2 = table_request_follow::find($followingid);
             $data2->update($new_json);
             return (new Response(array('status' => true, 'msg' => 'success'), 200))->header('Content-Type', "json");
         } else {
             return (new Response(array('status' => false, 'msg' => 'Authentication Failed2'), 200))->header('Content-Type', "json");
         }
     } else {
         return (new Response(array('status' => false, 'msg' => 'Authentication Failed1'), 200))->header('Content-Type', "json");
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $detail = table_users_detail::where('users_id', '=', $id)->first();
     if (isset($detail->users_detail_id)) {
         $idusersdetail = $detail->users_detail_id;
         table_users_detail::find($idusersdetail)->delete();
     }
     user::find($id)->delete();
     return redirect('admin/users-detail')->with('warning', 'Data have been removed!');
 }
示例#3
0
 public function upload()
 {
     if (Request::hasFile('file')) {
         $rules = array('file' => 'mimes:png,jpeg,jpg,bmp');
         $validator = Validator::make(Request::all(), $rules);
         if ($validator->fails()) {
             return (new Response(array('status' => false, 'msg' => 'Please choose a picture'), 200))->header('Content-Type', "json");
         } else {
             $str = "";
             try {
                 $param_picture = Request::input('param_picture');
                 $id = Request::input('param');
                 $token = Request::input('token');
                 $file = Request::file('file');
                 $filename = "";
                 $field_update = array();
                 if ($param_picture == "ava") {
                     $filename = md5('Avatar -' . date("Y-m-d H:i:s") . '-') . '.' . $file->getClientOriginalExtension();
                     $field_update = array('users_avatar' => $filename);
                 } else {
                     $filename = md5('Cover -' . date("Y-m-d H:i:s") . '-') . '.' . $file->getClientOriginalExtension();
                     $field_update = array('users_cover' => $filename);
                 }
                 $destinationPath = 'UPLOADED';
                 $file->move($destinationPath, $filename);
                 $data_find = table_users_detail::find($id);
                 $data_find->update($field_update);
                 $str = "success ";
                 return (new Response(array('status' => true, 'msg' => $str, 'f' => $filename), 200))->header('Content-Type', "json");
             } catch (Exception $e) {
                 $str = $e->getMessage();
                 return (new Response(array('status' => false, 'msg' => $str), 200))->header('Content-Type', "json");
             }
         }
     } else {
         return (new Response(array('status' => false, 'msg' => 'Authentication Failed'), 200))->header('Content-Type', "json");
     }
 }