My CountryController is in admin folder which has store function.
Web.php is:-
Route::prefix('admin')->group(function () {
Route::resource('country', 'admin\CountryController');});
HTML Code is:-
<form method="post" action="{{ route('admin/CountryController.store') }}">
It's showing error:- Route [admin/CountryController.store] not defined. (View: C:\xampp\htdocs\happyvivah\resources\views\admin\country.blade.php)
use 'php artisan route:list' command in CMD. it will show the name of all route. it will show route name 'country.store'.
so after replacing to route('admin/CountryController.store') with route('country.store') it will work.
Related
This is the error that I get rolled out
(View: Route [user.profile] not defined. (View: D:\Programi\XAMPP\htdocs\crushapp\resources\views\layouts\base.blade.php)
But my route is clearly defined here:
use App\Http\Livewire\User\ProfileComponent;
Route::middleware(['auth:sanctum','verified'])->group(function()
{
Route::get('/user/profile',ProfileComponent::class)->name('user.profile');
});
The error comes from the layout, namely:
<span><i class="fa fa-user-circle-o" aria-hidden="true"></i> {{ Auth::user()->name }} </span>
Any ideas what could it be?
UPDATE: Any new route I try defining under user won't work...
first you are missing a function name in your route
also run php artisan route:clear
Route::get('/user/profile',ProfileComponent::class, 'index')->name('user.profile')
i have this route:
Route::get('blog/search', 'web\BlogController#localSearch')->name($this->prefix.'blogSingle.localSearch');
this route it´s inside group:
Route::group(['prefix' => $locale, 'where' => ['locale' => '[a-zA-Z]{2}']], function(){
//Route::get('/', 'Web\HomeController#index')->name($this->prefix.'home.index');
Route::get('/', 'Web\ManagerController#index')->name($this->prefix.'home.index');
Route::get('about', 'Web\AboutController#index')->name($this->prefix.'about.index');
Route::get('contact', 'Web\ContactController#index')->name($this->prefix.'contact.index');
Route::get('help', 'Web\HelpController#index')->name($this->prefix.'help.index');
Route::get('local/{url}', 'Web\LocalController#index')->name($this->prefix.'local.index');
Route::get('privacy-policy', 'Web\PrivacyController#index')->name($this->prefix.'privacy.index');
Route::get('managers', 'Web\ManagerController#index')->name($this->prefix.'manager.index');
Route::get('blog', 'Web\BlogController#index')->name($this->prefix.'blog.index');
Route::get('search', 'Web\SearchController#index')->name($this->prefix.'search.index');
Route::get('suggest-local', 'Web\SuggestController#index')->name($this->prefix.'suggest.index');
Route::get('terms-conditions', 'Web\TermController#index')->name($this->prefix.'term.index');
Route::get('blog/{url}', 'web\BlogController#show')->name($this->prefix.'blogSingle.show');
Route::get('blog/likeit/{id}', 'web\BlogController#likeit')->name($this->prefix.'blogSingle.likeit');
Route::get('blog/search', 'web\BlogController#localSearch')->name($this->prefix.'blogSingle.localSearch');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController#showResetForm')->name($this->prefix.'password.reset');
Route::get('email/verify/{id}', 'Auth\VerificationController#verify')->name($this->prefix.'verification.verify');
});
}
but i need call to action form:
<form action="{{ route('blog/search') }}" method="get" class="fl-wrap" id="searchRestaurant">
and when send my form, returned this:
Route [blog/search] not defined. (View: C:\wamp64\www\guiaPaladar\resources\views\layouts\right_sidebar_blog.blade.php)
this error appear when blade load, so i can´t do anything
i don´t show my wrong, others routes i can use in other form, for example blog/likeit/{id} i used in href to add like in post blog...
i hope that anybody can help me, please. Sorry for my english
Thanks
If you are sure that the route blog/search is registered after using php artisan route:list to check. However, your change is not reflected; You may have to clear cache. Please use the following command:
php artisan route:clear
I have a problem with my edit page. When I submit I get this error:
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods:
POST
.
I have no clue where it comes from as I am pretty new to Laravel.
web.php
Route::post('/admin/add_reseller','ResellerController#addReseller');
Controller.php
public function addReseller(){
return view ('admin.resellers.add_reseller');
}
add_reseller.blade.php
<form class="form-horizontal" method="post" action="" name="addreseller" id="addreseller">
{{ csrf_field() }}
Tip:
First of all, I would use named routes, that means you add ->name('someName') to your routes. This makes the use of routes way easier and if you decide that your url doens't fit you don't need to change it everywhere you used the route.
https://laravel.com/docs/7.x/routing#named-routes
e.g. Route::post('/admin/add_reseller',
'ResellerController#addReseller')->name('admin.reseller');
Problem:
What I see is, that you lack the value for the action attribute in your <form>. The action is needed, so that the right route is chosen, if the form gets submitted.
Solution:
I guess you just have to add action="{{route('admin.reseller')}}" for the attribute, so that the request goes the right route.
<form class="form-horizontal" method="post" action="" name="addreseller" id="addreseller">
Your action in the form is empty, you need to add the corresponding route there.
I'd suggest you to use named routes.
https://laravel.com/docs/7.x/routing#named-routes
In web.php
Route::post('/admin/add_reseller','ResellerController#addReseller')->name('admin.add.reseller');
and then in your blade file you could refer to the route using the route() function by passing the name of the route as an argument
<form class="form-horizontal" method="post" action="{{route('admin.add.reseller')}}" name="addreseller" id="addreseller">
I've encountered a problem submitting my form in laravel. My form structure looks this.
<form class="form-group" action="{{ route('writepoem') }}"
method="post" name="publish" enctype="multipart/form-data"
onsubmit="return validateForm();">
<input type="hidden" name="_token" value="{{ Session::token() }}">
<input type="text" name="user">
<textarea name="poem"></textarea>
<input type="submit" value="save">
</form>
My web.php file has this route.
Route::post('/writepoem', ['uses'=>'PoemController#postCreatePoem','as'=>'writepoem']);
My PoemController.
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Poem;
class PoemController extends Controller
{
public function postCreatePoem(Request $request)
{
//validation
$poem=new Poem();
$poem->poem=$request['poem'];
$poem->user=$request['user'];
//save poem
$request->user()->poems()->save($poem);
return redirect()->route('feed');
}
}
On submitting my form I get this Exception.
(1/1) NotFoundHttpException
in RouteCollection.php line 179.
What could be the issue with routing?
If your route points site.com/writepoem and this route returns notfoundexception; this means 2 possible things;
1) Your route has a group and this group has a parent namespace for url
Route::group(['prefix' => 'poems'], function() {
Route::post('/writepoem', ['uses'=>'PoemController#postCreatePoem','as'=>'writepoem']);
});
2) Or your route file is cached. please try; php artisan route:clear & php artisan route:cache
I found that my form was linked to the main page via
`require resource_path().'/sub-folder/write.php'`
and that was causing the error.
I moved the form to the main document and my issue was fixed.
I had the same problem but now I fixed my problem.
You need to follow these steps. If you have written the right code and then you get this error, then you need to follow steps.
Clear cache php artisan route:clear & php artisan route:cache run command one by one. If your problem not fixed yet then you need to follow the second step also
Run this command to reload composer composer dump-autoload
I use the standard authentication mechanism in Laravel.
Route path is:
Route::post('auth/register', 'Auth\AuthController#postRegister');
HTML form is:
<form method="POST" action="/auth/register">
When I submit form I get 404 error.
But path for GET methos works:
Route::get('auth/register', 'Auth\AuthController#getRegister');
Use Laravel's helper function url() to generate an absolute URL. In your case the code would be:
<form method="POST" action="{{ url('auth/login') }}">
You could also check out the laravelcollective forms package. These classes were removed from the core after L4. This way you could build HTML forms using PHP only:
echo Form::open(['url' => 'auth/login', 'method' => 'post'])
you can use {{ URL::route('register') }} function in the action method. In This case the method will be:
action="{{ URL::route('register') }}"
and your route file will be:
`
Route::get('auth/register',array('as' =>'register' ,'uses' => 'Auth\AuthController#getRegister'));
Route::post('auth/register', array('as' =>'register' ,'uses' =>'Auth\AuthController#postRegister'));
`