i am trying to access one route like pages.trashmultiple this in my view. But its throwing error of Route [pages.trashmultiple] not defined.. Here is how my view looks like:
{!!Form::open([
'method' => 'put',
'route' => 'pages.trashmultiple'
])!!}
<th class="table-checkbox">
<input type="checkbox" class="group-checkable" data-set="#sample_3 .checkboxes"/>
</th>
{!!Form::close()!!}
This is how my controller looks like:
public function trashmultiple(Request $request){
//return "trash multiple page";
return Input::all();
}
And this is how my routes look like:
Route::group(['middleware' => ['web']], function () {
Route::get('pages/trash', 'PagesController#trashpage');
Route::get('pages/movetotrash/{id}', 'PagesController#movetotrash');
Route::get('pages/restore/{id}', 'PagesController#restore');
Route::get('pages/trashmultiple', 'PagesController#trashmultiple'); //this is not working
Route::resource('pages', 'PagesController');
});
When i load my url http://localhost:8888/laravelCRM/public/pages it shows me this below error:
ErrorException in UrlGenerator.php line 307:
Route [pages.trashmultiple] not defined. (View: /Applications/MAMP/htdocs/laravelCRM/resources/views/pages/pages.blade.php)
I want to know why i am unable to access the pages.trashmultiple when i have already defined it.
Is there any way i can make it accessible through pages.trashmultiple?
Thank you! (in advance)
chnage your route to like this:
Route::get('pages/trashmultiple', 'PagesController#trashmultiple');
To
Route::get('pages/trashmultiple', [
'as' => 'pages.trashmultiple', 'uses' => 'PagesController#trashmultiple'
]);
Change your route so that it becomes:
Route::get('pages/trashmultiple',
['as'=>'pages.trashmultiple',
'uses'=>'PagesController#trashmultiple']);
Related
I got error that says
Method App\Http\Controllers\Frontend\Atribut\AtributDashboardController::deleteData/{id} does not exist.
I write my routes like this :
Route::group([
'prefix' => 'atribut',
'as' => 'atribut.'
], function () {
Route::group(['prefix' => 'tabHome', 'as' => 'tabHome.'], function () {
Route::get('', [AtributDashboardController::class, 'showTab'])->name('showTab');
Route::post('', [AtributDashboardController::class, 'addData'])->name('addData');
Route::get('', [AtributDashboardController::class, 'deleteData/{id}'])->name('deleteData');
});
in the controller i also already write these :
public function deleteData($id)
{
$this->inpData->deleteData($id);
return redirect('atribut/tabHome');
}
i call $this->inpData->deleteData($id) from my models :
public function deleteData($id)
{
DB::table('inp_datas')->where('id', $id)->delete();
}
this is the button action when delete button pressed:
#forelse ($dataDisplay as $data)
<tr>
<td>{{$data->name}}</td>
<td>
Delete
</td>
</tr>
#empty
#endforelse
why it says the method does not exist?
As you can see in the documentation, the Route first argument is route name, and in the array you have to specify class and its method.
Why it says the method does not exist?
In your AttributDashboardController you have deleteData method, not deleteData/{id}. The deleteData/{id} is more likely to be a route name in your case.
So for your example, delete route should look like this:
Route::get('deleteData/{id}', [AtributDashboardController::class, 'deleteData'])->name('deleteData');
or:
Route::get('{id}', [AtributDashboardController::class, 'deleteData'])->name('deleteData');
Laravel is smart enough to pass the {id} parameter to your deleteData method as $id argument.
HTTP DELETE
Also, if you want to make delete at this route, you will probably benefit from reading about available router methods, and especially HTTP DELETE.
My controllers which are HomeController and BlogController in Admin folder. My views like:
/admin
index.blade.php
/blog
index.blade.php
I want to call /admin0admin url to /resources/views/admin/index.blade.php.
I want to call /admin0admin/blog url to /resources/views/admin/blog/index.blade.php
Here how i call in view:
<a href="{{ route('admin0admin.blog') }}" class="br-menu-link">
And my routes like:
Route::group(['namespace' => 'Admin', 'prefix' => 'admin0admin'], function () {
Route::get('/', 'HomeController#index')->name('index');
Route::group(['prefix' => 'blog'], function () {
Route::get('/', 'BlogController#index')->name('index');
});
});
And my BlogController index method:
return view('admin.blog.index');
I got an 404 not found error.
Route [admin0admin.blog] not defined
Laravel Version is : 5.6.*
You need to name the route admin0admin.blog, not index. prefix does not affect names of routes, so you need to write it out.
I have a problem. I tried to change the controller but when I open the route it doesn't reflect with the latest controller? Any idea?
Controller
public function indexApplication(){
return "testing";
}
Api.php
Route::group(['prefix' => '/claim'], function(){
Route::get('/test', ['as' => 'claim.test', 'uses' => 'ClaimController#indexApplication']);
}
Response from rest client
This is my route.php and I have also given the link of activate account. Then also "InvalidArgumentException
Route [account-activate] not defined." this error is coming:
<?php
Route::get('/',array(
'as'=>'home',
'uses'=>'HomeController#home'
));
//unauthenticated grp
Route::group(array('before'=>'guest'), function() {
//cross side request forgery protection
Route::group(array('before'=>'csrf'), function() {
//create acc(POST)
Route::post('/account/create',array(
'as'=>'account-create-post',
'uses'=>'AccountController#postCreate'
));
});
//create acc(GET)
Route::get('/account/create',array(
'as'=>'account-create',
'uses'=>'AccountController#getCreate'
));
});
You need to add a route to your routes.php file (located under app/) to define the 'account-activate' route that you are using to create the link in your e-mail.
If the function that will process the request is in the AccountController and it is called getAccountActivate then the route declaration will look like:
Route::get('/whateverUrlYouWant', [
'as' => 'account-activate',
'uses' => 'AccountController#getAccountActivate',
]);
You can use any URL, Controller and function. Put the URL you want to be associated with that route.
I have this route :
// work
Route::resource('work', 'WorkController');
Route::get('work/{id}/delete', array('as' => 'admin.work.delete', 'uses' => 'WorkController#confirmDestroy'))
->where('id', '[0-9]+');
and my controller WorkController is residing at App/Controllers/Admin
in the view I call it like this:
<span class="glyphicon glyphicon-book"></span> <br/>Work
and I get this error:
Error Message: Class App\Controllers\Admin\Work does not exist
What is wrong with my code? I have used the same approach for pages, users and menus and it worked.
Can you confirm what is the name of controller file in App\Controllers\Admin?. Also your route should be
// work
Route::group(array('prefix' => 'admin', function()
{
Route::resource('work', 'WorkController');
Route::get('work/{id}/delete', array('as' => 'admin.work.delete', 'uses' => 'WorkController#confirmDestroy'))
->where('id', '[0-9]+');
});