0

I can't fix this error: Route *[admin.conditions.update]* not defined. I checked some other posts with the same question, but still can't figure it out.

I checked php artisan route:list. For conditions.update the path was :

admin/conditions/{condition} App/http/controllers/ConditionsController@update

The routes in web.php:

Route::group( ['prefix'=>'admin'] , function()
{
    Route::resource('/conditions','conditionsController');

    Route::get('index' , function() 
    {
        return View('admin.index');
    });
});

My edit.blade.php route:

{!! Form::model( $record , ['method'=>'PATCH' , 'route'=>['admin.conditions.update', $record->id] ] ) !!}

Error is:

Route [admin.conditions.update] not defined. (View: C:\wamp64\www\dbsystem\resources\views\admin\conditions\edit.blade.php)*

Some following errors:

in UrlGenerator.php line 304
at CompilerEngine->handleViewException(object(InvalidArgumentException), 1)in PhpEngine.php line 44

at PhpEngine->evaluatePath('C:\\wamp64\\www\\dbsystem\\storage\\framework\\views/e2e78c3d81e946fdb92174f035a7944bab024389.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'record' => object(ConditionsModel)))in CompilerEngine.php line 59

at CompilerEngine->get('C:\\wamp64\\www\\dbsystem\\resources\\views/admin/conditions/edit.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'record' => object(ConditionsModel)))in View.php line 137

at View->getContents()in View.php line 120
D Malan
  • 10,272
  • 3
  • 25
  • 50
mj1200
  • 3
  • 2
  • You can run `php artisan route:list` to see the routes you have defined. – Qirel Jul 26 '19 at 10:24
  • Possible duplicate of [Laravel 5 route not defined, while it is?](https://stackoverflow.com/questions/28714675/laravel-5-route-not-defined-while-it-is) – atymic Jul 26 '19 at 10:25
  • What version of Laravel are you using? – Rwd Jul 26 '19 at 10:35

1 Answers1

3

The reason your route name isn't working is because prefix only works for the url/uri. To prepend to the route names inside a group as well you need to provide an as to the group:

Route::group(['prefix' => 'admin', 'as' => 'admin.'], function () {
    Route::resource('/conditions', 'conditionsController');

    Route::get('index', function () {
        return View('admin.index');
    });
});

Notice the 'as' => 'admin.'. Don't forget the . on the end.

Rwd
  • 34,180
  • 6
  • 64
  • 78