/** * 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; }
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); }
/** * 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); }); }
public function cancel($id) { $problem = Problem::findOrFail($id); $problem->delete(); return redirect('problems')->with(["status" => "Problem has been Deleted", 'currentProblem' => $problem]); }