Avatar of Bruce Gust
Bruce Gust
Flag 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:


What 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?

PHPLaravel

Avatar of undefined
Last Comment
Bruce Gust

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Chris Stanyon

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes