0

Call to undefined function routes() (View: C:\xampp\htdocs\Julmarice\framework\resources\views\soulfy\apages.blade.php)

Why this is undefine?

apages.blade.php

<form action="{{ routes('navcolor') }}" method="post">    
                    <div style="color: white;">Select Pages Navigation Color :</div>
                    {{ csrf_field() }}          
                    <select name="NavColor">
                        <option value="black">Black</option>
                        <option value="blue">Blue</option>
                        <option value="gray">Gray</option>
                        <option value="brown">Brown</option>
                    </select>

                    <input type="submit" value="Submit"><br><br> 
                    </form>

routes.php

 Route::post('/home/navcolor', 'SettingController@postNavColor')->name('navcolor');

SettingController.php

public function postNavColor(Request $request)
 {
   $domain = $_SERVER['SERVER_NAME'];
   $user = User::where('domain', $domain)->first();

   $user_id = $user->id;

   $nav_color = $request->get('navcolor');

   DB::table('user_profile')->where('user_id', $user_id)
                            ->update(['nav_color' => $nav_color]);

   return view('/soulfy/apages');                        

    }
2
Contributors
5
Replies
34
Views
1 Month
Discussion Span
Last Post by davy_yg
0

Hi,

supposing you are not trying to load a user defined function named routes(), have you read the documentation? https://laravel.com/docs/5.5/routing#named-routes and the source in which this function should be defined? Does exists?

Use an editor that can autocomplete the code, in SublimeText for example, when you hover a method/function it shows you in which files this is defined and you can click it to see the code. Also add a linter plugin to enlight obvious mistypes and forgotten operators.

0

I still do not understand what I did wrong. Am I wrong to define name on the post routes?

Route::post('/home/navcolor', 'SettingController@postNavColor')->name('navcolor');
0

The name is well defined, otherwise you would get an exception:

Route [navcolor] not defined.

The error message says Call to undefined function routes(), which in other words means that the function you are trying to call does not exists. Have you read the documentation? I posted the link for you in my previous message. You already have the solution, you could have solved this hours ago.

0

I cannot find away to fix the error still remains.

ErrorException in 2446bfd75c7add3bbde8907ba5aecdc0 line 48: Call to undefined function routes() (View: C:\xampp\htdocs\Julmarice\framework\resources\views\soulfy\apages.blade.php)

line 48:

apages.blade.php

<form action="{{ routes('navcolor') }}" method="post">   
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.