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

Why this is undefine?


<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>

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


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


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');                        


Recommended Answers

All 5 Replies


supposing you are not trying to load a user defined function named routes(), have you read the documentation? 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.

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');

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.

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:


<form action="{{ routes('navcolor') }}" method="post">   

It is solved. I forget how to but it is solved. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.