路线[companies.show]未定义

I am getting this error (Route [companies.show] not defined.) and I don't know what to do. Actually I am updating the data in CompaniesController and data is updating but the route is not working Here is the code for that:

public function update(Request $request, Company $company){
$companyUpdate = Company::where('id', $company->id)->update(['name'=> $request->input('name'),'description'=> $request->input('description')]);
if($companyUpdate){
return redirect()->route('companies.show', ['company'=> $company->id])
      ->with('success' , 'Company updated successfully');
    }
 return back()->withInput();

And My web.php file is as follow `

Route::get('/', function () {
return view('welcome');});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::resource('/company','CompaniesController');

Thanks in advance for helping me

change companies.show to

return redirect()->route('company.show', ['company'=> $company->id])
  ->with('success' , 'Company updated successfully');
}

companies.show is undefined because you didn't give your route a name.

Route::get('/companies/{id}', 'CompaniesController@showCompanyForID')->name('companies.show');

Create a function called showCompanyForID in your CompaniesController and return the company which has the id requested for in your Request.

use Illuminate\Http\Request;

public function showCompanyForID(Request $request)
{
    $id = isset($request->id) ? $request->id : 0;
    if ($id) {
        // do work here
    }
    return view('companies.company')->with(compact('var1', 'var2'));
}

You can now redirect to that route:

return redirect()
  ->route('companies.show')
  ->with(['company'=> $company->id, 'success' => 'Company updated successfully']);

To see all routes, cd to your project in cmd / Terminal and type: php artisan route:list