Esempio n. 1
0
 public function friendSearch()
 {
     // Retrieve the user's input and escape it
     $query = e(Input::get('q', ''));
     // If the input is empty, return an error response
     if (!$query && $query == '') {
         return Response::json(array(), 400);
     }
     $user = UserInfo::where('firstname', 'like', '%' . $query . '%')->orWhere('lastname', 'like', '%' . $query . '%')->with('user')->orderBy('firstname', 'asc')->take(6)->get()->toArray();
     $user = $this->friends($user);
     //$user = $this->appendValue($user,'check');
     return Response::json(array('data' => $user));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $path = public_path();
     $parentDir = $path . '/img/users/' . Auth::user()->email . '/';
     if (!is_dir($parentDir)) {
         return "Error";
     }
     if (Input::hasFile('avatar')) {
         if (Input::file('avatar')->isValid()) {
             $file = Input::file('avatar');
             if (substr($file->getMimeType(), 0, 5) == 'image') {
                 // this is an image
                 $img = Image::make($file);
                 $img = (string) Image::make($img)->encode('jpg', 100);
                 Image::make($img)->save($parentDir . 'avatar_orig.jpg');
                 Image::make($img)->resize(255, 250, function ($constraint) {
                     $constraint->aspectRatio();
                     $constraint->upsize();
                 })->save($parentDir . 'avatar_big.jpg');
                 Image::make($img)->resize(155, 150, function ($constraint) {
                     $constraint->aspectRatio();
                     $constraint->upsize();
                 })->save($parentDir . 'avatar_med.jpg');
                 Image::make($img)->resize(50, 50, function ($constraint) {
                     $constraint->aspectRatio();
                     $constraint->upsize();
                 })->save($parentDir . 'avatar_small.jpg');
                 $image_url = UserInfo::where('user_id', Auth::user()->id)->firstOrFail();
                 if ($image_url) {
                     $image_url->image_url = '../img/users/' . Auth::user()->email . '/avatar_med.jpg';
                     $image_url->save();
                 }
                 return './img/users/' . Auth::user()->email . '/avatar_med.jpg?';
             } else {
                 return "Error";
             }
         } else {
             return "Error";
         }
     } else {
         return "Error";
     }
 }
Esempio n. 3
0
 public function lookUp($type)
 {
     $query = e(Input::get('q', ''));
     if (!$query && $query == '') {
         return Response::json(array(), 400);
     }
     $user = UserInfo::where('firstname', 'like', '%' . $query . '%')->orWhere('lastname', 'like', '%' . $query . '%')->with('user')->orderBy('firstname', 'asc')->take(6)->get()->toArray();
     if ($type == 'Favourites') {
         $user = $this->favourites($user);
     } else {
         if (Auth::check()) {
             $user = $this->removeMyself($user);
             $user = $this->appendValue($user, 'username');
         } else {
             $user = $this->appendValue($user, 'username');
         }
     }
     return Response::json(array('data' => $user));
 }
 /**
  * [Handle the command]
  * @param  [type] $command [description]
  * @return [type]          [description]
  */
 public function handle($command)
 {
     $user = UserInfo::register($command->firstname, $command->lastname, $command->gender, $command->user_id, $command->image_url);
     $this->repository->save($user);
     return $user;
 }