v Sugumar v Sugumar - 2 years ago 409
PHP Question

Laravel : Overriding route for specific route in voyager

I am trying to override a route for creating a row. (posting, not viewing)


In web.php

I modified

Route::group(['prefix' => 'admin'], function () {
Route::post('/cpu-speed',['uses' => 'Admin\Mobiles\CPUSpeedController@store', 'as' => 'store']);


Also I created Controller

namespace App\Http\Controllers\Admin\Mobiles;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class CPUSpeedController extends Controller
public function store(){
return 'hello';

public function create(){
return 'create';

But it throws the following error:

ErrorException (E_ERROR) Route [voyager.cpu-speed.store] not defined.

Answer Source

It appears you are only naming it store here:

Route::post('/cpu-speed',['uses' => 'Admin\Mobiles\CPUSpeedController@store',  'as' => 'store']);

It should probably be:

Route::post('/cpu-speed',['uses' => 'Admin\Mobiles\CPUSpeedController@store',  'as' => 'voyager.cpu-speed.store']);

I'm not entirely sure this will work, since it may be interpreted and descend into the Voyager package, rather than just reading your web.php file, but I believe it will do what you like.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download