/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $role = Auth::user()->roles;
     $admin_count = 1 << 0 & $role ? User::where('roles', '>', '0')->count() : -1;
     $problem_count = 1 << 1 & $role ? Problem::count() : -1;
     $user_count = 1 << 2 & $role ? User::count() : -1;
     $contest_count = 1 << 3 & $role ? Contest::count() : -1;
     $group_count = 1 << 4 & $role ? Group::count() : -1;
     $news_count = 1 << 5 & $role ? News::count() : -1;
     $discuss_count = 0;
     $runinfo_count = 1 << 7 & $role ? Status::count() : -1;
     return response()->json(['admin_count' => $admin_count, 'problem_count' => $problem_count, 'user_count' => $user_count, 'contest_count' => $contest_count, 'group_count' => $group_count, 'news_count' => $news_count, 'discuss_count' => $discuss_count, 'runinfo_count' => $runinfo_count]);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request)
 {
     //
     $contestDefault = Contest::where('default', '=', 'Yes')->get()->first();
     $contestant = Contestant::find($request->id);
     $contestant->full_name = $request->full_name;
     $contestant->email = $request->email;
     $contestant->phone = $request->phone;
     $contestant->region_id = $request->region;
     $contestant->district_id = $request->district;
     $contestant->city = $request->city;
     $contestant->zone = $request->zone;
     $contestant->registration_date = date("Y-m-d");
     $contestant->profile_note = $request->profile_note;
     $contestant->status = "Active";
     $contestant->dob = $request->dob;
     $contestant->contest_year = date("Y");
     if (count($contestDefault) > 0 && $contestDefault != null && $contestDefault != "") {
         $contestant->contest_id = $contestDefault->id;
     }
     $contestant->save();
     if ($request->uploadedFileName != "") {
         $newfile = config('app.contestant_image_profile') . $request->uploadedFileName;
         $oldfile = config('app.contestant_image_profile_tmp') . $request->uploadedFileName;
         if (!File::exists($newfile)) {
             File::move($oldfile, $newfile);
             $contestant->profile_image = $request->uploadedFileName;
             $contestant->save();
             ///
             //Copy to front folder
             $file_namenw = config('app.contestant_front_image_profile') . $request->uploadedFileName;
             File::copy($newfile, $file_namenw);
         } else {
             $contestant->profile_image = $request->uploadedFileName;
             $contestant->save();
             //Copy to front folder
             $file_namenw = config('app.contestant_front_image_profile') . $request->uploadedFileName;
             File::copy($newfile, $file_namenw);
         }
     }
     return redirect('contestant/manage');
 }
 public function p($id)
 {
     return view('contests.contest.pshow')->with(["data" => Problem::find($id), "contest" => Contest::find(session('cid')), "extendsJS" => true]);
 }