/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $users = User::where('id', '!=', Auth::id())->where('priviledge', '!=', 'superuser')->get();
     if (Auth::user()->priviledge != 'superuser') {
         $weights = Vote::where('user_id', '=', Auth::id())->sum('performance');
         $sum = $weights;
     }
     //echo "<pre>";
     //var_dump($users);die;
     foreach ($users as $key => $value) {
         $path[$key] = file::where('user_id', '=', $value['id'])->pluck('path');
         //echo "<pre>";
         //var_dump($path);die;
     }
     return View::make('votes.home', compact(Auth::user()->user_name, 'users', 'sum', 'path'));
 }
 public function picture_update()
 {
     $validator = Validator::make(Input::all(), file::$rules);
     if ($validator->fails()) {
         Session::flash('error', 'uploaded file is not valid');
         return Redirect::back()->withInput()->withErrors($validator->messages());
     }
     $data = file::where('user_id', '=', Auth::user()->id)->pluck('path');
     $file = Input::file('image');
     $extension = $file->getClientOriginalExtension();
     $filename = Auth::user()->id . '.' . $extension;
     $file->move('uploads', $filename);
     $path = '../uploads/' . $filename;
     $picture = new file();
     $picture->user_id = Auth::user()->id;
     $picture->path = $path;
     if ($data == null) {
         $picture->save();
     } else {
         $picture->update();
     }
     return Redirect::back();
 }