/**
  * problem is saved
  * @param problem id, Request object
  */
 public function solved($id)
 {
     $problem = Problem::findOrFail($id);
     if (isset($_POST['solved'])) {
         $problem->solved = 1;
         $problem->save();
         return view('Pages.individual-problems')->with(["status" => "Problem status has been changed to Complete", 'currentProblem' => $problem]);
     }
     return $problem;
 }
Example #2
0
 public function index()
 {
     $latestArticles = Article::latest()->take(6)->get();
     $latestPosts = Post::latest()->take(6)->get();
     $latestProblems = Problem::latest()->take(6)->get();
     $latestGroups = Group::latest()->take(6)->get();
     $latestUsers = User::latest()->take(6)->get();
     $ratedUsers = User::orderBy('rate', 'desc')->take(6)->get();
     $chartDatas = Comment::select([DB::raw('DATE(created_at) AS date'), DB::raw('COUNT(id) AS count')])->groupBy('date')->orderBy('date', 'ASC')->get()->toArray();
     return view('admin.dashboard.index', compact('latestArticles', 'latestPosts', 'latestProblems', 'latestGroups', 'latestUsers', 'ratedUsers', 'chartDatas'))->with(['title' => 'Admin Dashboard Panel']);
 }
 public function showProblem(\Illuminate\Http\Request $request)
 {
     try {
         $collection = \App\Collection::findOrFail($request->route('cid'));
         $problem = \App\Problem::findOrFail($request->route('pid'));
     } catch (ModelNotFoundException $e) {
         \Session::flash('errorMsg', 'Problem not found!');
         return \Redirect::back();
     }
     return \View::make('probleminfopage')->with('problem', $problem)->with('collection', $collection);
 }
Example #4
0
 public static function getProblems($idContest, $idUser)
 {
     $problemas = DB::table('problemas')->join('contest_problem', 'contest_problem.problem_id', '=', 'problemas.id')->where('contest_problem.contest_id', '=', $idContest)->select('problemas.id', 'contest_problem.color')->orderBy('problemas.id', 'asc')->get();
     $response = array();
     foreach ($problemas as $problem) {
         $solucion = DB::table('envios')->where('envios.id_usuario', '=', $idUser)->where('envios.id_problema', '=', $problem->id)->where('envios.id_concurso', '=', $idContest)->where('envios.veredicto', '=', 1)->select('envios.*')->first();
         $intentos = DB::table('envios')->where('envios.id_usuario', '=', $idUser)->where('envios.id_problema', '=', $problem->id)->where('envios.id_concurso', '=', $idContest)->where('envios.veredicto', '!=', 1)->select(DB::raw('count(envios.id) as intentos'))->first();
         $color = Problem::getColor($idContest, $problem->id);
         $ans = (object) array("solucion" => $solucion, "intentos" => $intentos->intentos, 'color' => $color);
         array_push($response, $ans);
     }
     return $response;
 }
 /**
  * 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]);
 }
Example #6
0
 public static function mark(Request $request)
 {
     if (empty($request->mark) && $request->mark != 0 || empty($request->idproblem)) {
         return \Response::json('Missing parameters!');
     }
     $problem = Problem::where('idproblem', $request->idproblem)->first();
     //missing check if user is really CR of this city
     $problem->mark = $request->mark;
     $problem->lastactivity = date('Y-m-d H:i:s', time());
     $problem->save();
     return \Response::json('Done');
 }
    var_dump($query);
});*/
Route::filter('csrf', function ($route, $request) {
    if (strtoupper($request->getMethod()) === 'GET') {
        return;
        // get requests are not CSRF protected
    }
    $token = $request->ajax() ? $request->header('X-CSRF-Token') : Input::get('_token');
    if (Session::token() != $token) {
        throw new Illuminate\Session\TokenMismatchException();
    }
});
Route::get('/', function () {
    $totalProblems = Problem::count();
    $solvedProblems = Problem::where('solved', 1)->get()->count();
    $unsolvedProblems = Problem::where('solved', 0)->get()->count();
    return view('Pages.index', ['totalProblems' => $totalProblems, 'solvedProblems' => $solvedProblems, 'unsolvedProblems' => $unsolvedProblems]);
});
Route::get('donner', 'HomeController@index');
// Authentication routes...
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::get('needy', 'ProblemController@needyForm');
/*handle post request to save form data*/
Route::post('needy', 'ProblemController@save');
/*donner button routes*/
Route::post('donate-money-req/{id}', 'DonnerController@returnDonateMoneyView')->middleware('donor-auth');
Route::get('donate-money-req/{id}', function () {
    return view("Pages.donate-money");
})->middleware('donor-auth');
Route::post('donate-money', 'DonnerController@charge');
Route::post('donate-money-main', 'DonnerController@saveDetails');
Example #8
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     //        $router->model('user' , 'App\User');
     $router->bind('user', function ($value) {
         return User::with('roles')->findOrFail($value);
     });
     /**
      * created by dara on 6/9/2015
      * add binding for admin wild card
      */
     $router->bind('admin', function ($value) {
         return User::with('roles')->findOrFail($value);
     });
     /**
      * Created by Emad Mirzaie on 09/09/2015.
      * province wild cart
      */
     $router->model('province', 'App\\Province');
     $router->model('city', 'App\\Province');
     $router->model('university', 'App\\University');
     $router->model('article', 'App\\Article');
     $router->model('post', 'App\\Post');
     $router->model('category', 'App\\Category');
     $router->model('sub_category', 'App\\Category');
     $router->model('skill', 'App\\Skill');
     $router->model('profile', 'App\\User');
     $router->model('comment', 'App\\Comment');
     $router->model('poll', 'App\\Poll');
     $router->model('questionnaire', 'App\\Questionnaire');
     $router->model('coupon_user', 'App\\CouponUser');
     $router->model('showcase', 'App\\Showcase');
     $router->model('sticky', 'App\\Sticky');
     /**
      * Created By Dara on 22/10/2015
      */
     //        $router->bind('offer',function($value){
     //            return Offer::findOrFail($value);
     //        });
     $router->bind('service', function ($value) {
         return CouponGallery::findOrFail($value);
     });
     $router->bind('coupon', function ($value) {
         return Coupon::findOrFail($value);
     });
     $router->bind('group', function ($value) {
         return Group::findOrFail($value);
     });
     $router->bind('problem', function ($value) {
         return Problem::findOrFail($value);
     });
     $router->model('offer', 'App\\Offer');
     $router->model('shop', 'App\\Shop');
     $router->model('product', 'App\\Product');
     $router->bind('event', function ($value) {
         return Event::findOrFail($value);
     });
     $router->bind('settle', function ($value) {
         return Settle::findOrFail($value);
     });
     $router->bind('report', function ($value) {
         return Report::findOrFail($value);
     });
     $router->bind('corporation', function ($value) {
         return Corporation::findOrFail($value);
     });
     /**
      * Created By Dara on 25/12/2015
      */
     $router->bind('announcement', function ($value) {
         return Announcement::findOrFail($value);
     });
     $router->bind('storage', function ($value) {
         return Storage::findOrFail($value);
     });
     $router->bind('role', function ($value) {
         return Role::findOrFail($value);
     });
 }
Example #9
0
 public function adminDelete(User $user, Problem $problem)
 {
     $problem->delete();
     Flash::success(trans('admin/messages.problemDeleted'));
     return redirect()->back();
 }
Example #10
0
 public function deleteProblem(Request $request)
 {
     $problema = Problem::find($request->input('id'));
     $problema->delete();
     return redirect('admin/problem');
 }
Example #11
0
 /**
  * Get all problems
  *
  * @return Collection
  */
 public function forAll()
 {
     return Problem::all();
 }
Example #12
0
 public function p($id)
 {
     return view('contests.contest.pshow')->with(["data" => Problem::find($id), "contest" => Contest::find(session('cid')), "extendsJS" => true]);
 }
Example #13
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $issubmit = false;
     $isac = false;
     if (Auth::check()) {
         $user_id = Auth::user()->user_id;
         $issubmit = DB::table('solution')->where('problem_id', $id)->where('user_id', $user_id)->count() > 0;
         $isac = DB::table('solution')->where('problem_id', $id)->where('user_id', $user_id)->where('result', 4)->count() > 0;
         if ($isac) {
             $issubmit = false;
         }
     }
     return view('problems.show')->with(["data" => Problem::find($id), "accepted" => $isac, "submited" => $issubmit, "extendsJS" => true]);
 }
Example #14
0
 public function problem(Request $request, Problem $problem)
 {
     $group = $problem->parentable;
     if ($request->user()->can('join-group', [$group])) {
         return ['hasCallback' => 0, 'callback' => '', 'hasMsg' => 1, 'msg' => 'تنها اعضای گروه می توانند پاسخ خود را برای این پرسش بیان نمایند.', 'msgType' => 'danger', 'returns' => ['num_comments' => '']];
     }
     $user = Auth::user();
     $comment = $problem->comments()->create(['user_id' => $user->id, 'body' => $request->input('body'), 'num_like' => 0, 'num_dislike' => 0]);
     $num_comments = $problem->comments()->count();
     $problem->update(['num_comment' => $num_comments]);
     $this->groupStream($comment);
     return ['hasCallback' => 1, 'callback' => 'post_comment', 'hasMsg' => 0, 'msg' => '', 'msgType' => '', 'returns' => ['new_comment' => view('partials.problemComment', compact('user', 'comment', 'problem'))->render(), 'num_comments' => $num_comments]];
 }
Example #15
0
 public function showProblemas($contest_id)
 {
     $contest = Concurso::find($contest_id);
     $data = ['contest' => $contest, 'problemas' => Problem::all()];
     return view('contest/problemas', $data);
 }
 public function cancel($id)
 {
     $problem = Problem::findOrFail($id);
     $problem->delete();
     return redirect('problems')->with(["status" => "Problem has been Deleted", 'currentProblem' => $problem]);
 }
 /**
  * Update the donner dashboard
  * fetch new requests from db
  * responds to post request on /update-donner-dashboard route
  */
 public function updateDashboard(Request $request)
 {
     $count = 0;
     $mainCount = 0;
     //first check if the cookie is set or not
     //this code will run when the count cookie is set
     if (Cookie::get('count')) {
         //fetch only difference records(new records)
         $count = Problem::count();
         //check if new rows have been added to the table then send the new reply
         //else no need to send data
         if (Cookie::get('count') != $count) {
             //if user entered a new form
             if ($count > Cookie::get('count')) {
                 $mainCount = $count - Cookie::get('count');
                 $problems = Problem::orderBy('id', 'desc')->take($mainCount)->get();
                 $response = new Response($problems);
                 $response->withCookie(cookie()->forever('count', $count));
                 return $response;
             }
             if ($count < Cookie::get('count')) {
                 $response = new Response("No New Problems");
                 return $response;
             }
             //$mainCount = max($count , Cookie::get('count')) - min($count , Cookie::get('count'));
             //setcookie("mainCount", $mainCount);
             //setcookie("1", "cookie was set but counts were not equal");
         } else {
             $response = new Response("No New Problems");
             return $response;
         }
     } else {
         //fetch all records
         //this code will run first time when count cookie is not set
         $problems = Problem::orderBy('id', 'desc')->get();
         $count = $problems->count();
         //this cookie will expire in next 5 years
         $response = new Response($problems);
         $response->withCookie(cookie()->forever('count', $count));
         return $response;
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     Problem::create($request->all());
     return redirect()->route('problem.index');
 }