Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

Why am I getting this 404 error?

Here's my method:


public function update(Request $request)
    {       $test_results= CeuResult::findOrFail($request->the_quiz_id);       if($request->pass <> $test_results->pass) {          if($request->pass==1) {             $test_results->attempts=1;             $test_results->quiz_date=date('Y-m-d');             $test_results->status='PASSED';             $test_results->pass=1;             $test_results->save();          }          else {             $test_results->attempts=0;             $test_results->pass=$request->pass;             $test_results->quiz_date=NULL;             $test_results->status=NULL;             $test_results->save();          }       }              $customer=CeuUser::findOrFail($request->the_id);          //update ceu_users table          $customer->winclose=$request->winclose;          $success='User was successfully updated!';                    if($customer->save()) {             Session::flash('message', 'User was successfully updated!');             return redirect('/admin/show/cuser/'.$request->the_id);          }        }

Open in new window

Here's a screenshot of the site we're looking at:


User generated imageWhat I need to do is update the "Window Close" date. 


That will happen at this point in the code:


$customer=CeuUser::findOrFail($request->the_id);
         //update ceu_users table
         $customer->winclose=$request->winclose;
         $success='User was successfully updated!';


The thing is, when I click on submit, I get a 404 error. 


My routes look like this:


    Route::get('/list/cuser', 'CUserController@index')->name('adminListCUsers');
   Route::get('/show/cuser/{id}', 'CUserController@show')->name('adminShowCUser');    Route::post('/update/cuser', 'CUserController@update')->name('adminUpdateCUser');    Route::post('/update/cuser/status', 'CUserController@update_status')->name('adminUpdateCUserStatus');    Route::post('/delete/cuser', 'CUserController@destroy')->name('adminDeleteCUser');

Open in new window

I can do this:


public function update(Request $request)
    {

     echo "hello";


...and get a "hello," so this:


Route::post('/update/cuser', 'CUserController@update')->name('adminUpdateCUser');


...is working fine. 


But something's going south within the function housed in the Controller and I'm not even sure how to troubleshoot it. 


Why would I get a 404? How do I figure out what's wrong?

ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruce Gust

ASKER

Didn't have a quiz id. Didn't need one to do what had to be accomplished. Threw an IF clause into the mix and the sun came out again!

Thanks, Chris!