2

Route [settings] not defined. (View: C:\xampp\htdocs\laravel\UserManagementSystem\resources\views\layouts\app.blade.php)

I wanted to create a user profile updation. i created the blade fields and all necessary fields but when i run the program it shows the error

This is my web.php

<?php
Route::get('/', function () {
return view('welcome');
});

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');

Route::group( ['middleware' => ['auth']], function() {
Route::resource('users', 'UserController');

Route::resource('roles', 'RoleController');
Route::resource('posts', 'PostController');
Route::resource('settings', 'SettingsController');
});

And my app.blade.php is

<a href="{{ route('settings') }}"
onclick="event.preventDefault();                                                 
document.getElementById('settings-form').submit();">
<i class="glyphicon glyphicon-log-out"></i> Settings
</a>

<form id="settings-form" action="{{ route('settings') }}" method="POST" 
style="display: none;">
{{ csrf_field() }}
</form>

Any one please help me. I am stuck with my work

vimuth
  • 5,064
  • 33
  • 79
  • 116
  • You're trying to access a route with name 'settings' but have no name for it. check this https://stackoverflow.com/questions/25290229/laravel-named-route-for-resource-controller – Sérgio Reis Mar 28 '18 at 09:02

4 Answers4

2

Change your route() method to url() like shown bellow.

<a href="{{ url('settings') }}"
onclick="event.preventDefault();                                                 
document.getElementById('settings-form').submit();">
<i class="glyphicon glyphicon-log-out"></i> Settings
</a>

<form id="settings-form" action="{{ url('settings') }}" method="POST" 
style="display: none;">
{{ csrf_field() }}
</form>
2

use@storefor storing data in database

in .blade.php file

<form id="settings-form" action="{{ route('settings') }}" method="post">

@csrf </form>

In web.php

Route::post('settings', 'SettingsController@store')->name('settings');
0

Try route('setting.{resource function-name}'); like route('setting.index)
or route('setting.show', ['id'=> 'setting_id']);

instead of just route('setting');

you are using a

Route::resource('settings', 'SettingsController');

you have to specify which function using in a resource route. If you want to know which function there are in your resource controller check out this link:

https://laravel.com/docs/5.7/controllers

AnoeD
  • 1
0

try this:

Route::get('settings', 'SettingsController')->name('settings');

or

Route::resource('settings', 'SettingsController')->name('settings);
Roberto Caboni
  • 7,252
  • 10
  • 25
  • 39