This is the mean problem
I have controllers structures like this
And i am using this syntax to make routes which is worked good for me
And i calling url in this way
{{ route('admin.categories.show', [$category->id]) }}
i got this error
Any Solution ?? thanks in advance guys
When grouping routes, it is possible to namespace them by adding flag as:
Route::group(['prefix' => 'admin', 'as' => 'admin.'], function (){
Route::resource('categories', 'Admin/CategoryController');
});
Now route('admin.categories.show') should be accessible.
the solution is
{{ route('categories.show', [$category->id]) }}
skip the admin thanks every one .
Related
I have created my own custom function in my RoomsController
public function join($id){
return $id;
}
Then I want to pass variable to it and it says MethodNotAllowedHttpException
And my Form looks like this
{{Form::open(['action'=> ['RoomsController#join', $room->id], 'method' => 'POST' ])}}
{{Form::submit('Join', ['class' => 'btn btn-danger'])}}
{{Form::close()}}
Also have these routes
Route::get('/','PagesController#index');
Route::get('/about', 'PagesController#about');
Route::get('/services', 'PagesController#services');
Route::get('/register', 'PagesController#register');
Route::get('/logout', 'PagesController#logout');
Route::get('/rooms/join', 'RoomsController#join');
Route::resource('posts','PostsController');
Route::resource('rooms','RoomsController');
Auth::routes();
Route::get('/dashboard', 'DashboardController#index');
I have tried in many different ways i dont know why it is not working. All update edit destroy resource functions are working. Thank's for helping :)
You're submitting a POST request but the route is expecting a GET request. If you change your route to Route::post('/rooms/join', 'RoomsController#join'); it should work
change the method to post and put the route below the resource route
Route::resource('rooms','RoomsController');
Route::post('/rooms/join', 'RoomsController#join');
I working on a simple laravel 5.2 application. I want to pass a value $id from the view when a button is clicked to the controller method destroy(). This is what i have tried:
This is my route
Route::get('delete/{id}', array('as' => 'delete', 'uses' => 'ContactsController#destroy'));
... and this is my button in a view:
Delete
But this code didn't work. Thanks for any help.
According to the documentation you should be able to do this:
{{ action('ContactsController#destroy', ['id' => $contacts->id]) }}
Your route is expecting an id so you don't need to pass an identifier. The below code should work for you.
Make sure you're using the correct brackets as by default in Laravel 5.2 you'll need to use {!! !!} instead of {{ }}.
Delete
Since it is a GET request, you can simply have you own href instead of using blade. I just find this more readable:
Delete
I have this route
Route::get('/dashboard', array(
'as' => 'dashboard-get',
'uses' => 'AppController#getDashboard'
));
In the View if i write
Dashboard
It will return me the entire link.
http://192.168.0.1/dashboard
How can get the route by name in the VIEW and only print the
/dashboard
Without the http://192.168.0.1/ part of the link
From the code source, route method generate an absolute URL by default, you may set it to false:
Dashboard
Update
You can also define your own custom links by
HTML::macro('Rlinks',function($routeName,$parameters = array(),$name){
return "<a href=".substr(URL::route($routeName,$parameters,false), 1) .">"
.$name.
"</a>";
});
Then call your macro
{{ HTML::Rlinks('dashboard-get',array(),'Dashboard') }}
You may try something like this:
app('router')->getRoutes()->getByName('dashboard-get')->uri();
My current website is in Codeigniter: http://www.tenders.af I want to convert it to
Laravel 4.1
I faced this problem with routing and I could not solved it yet any help will be appreciated.
my routes in codeigniter:
$route['afghanistan-tenders/(:any)'] = 'home/details/$1';
how can I write like the above route in Laravel 4 or 4.1
Route::get('/afghanistan-tenders/{id}', ['uses' => 'HomeController#details']);
Then in your HomeController
public function details($id)
{
echo $id;
}
Edit: based upon your comment below - can you just do this?
Route::get('/afghanistan-tenders/{id}/school-development', ['uses' => 'HomeController#details']);
or
Route::get('/afghanistan-tenders/{id}/{name}', ['uses' => 'HomeController#details']);
I try to handle the default route of a route group, I have this but it doesn't work.
Route::group(array('prefix' => 'administrator'), function() {
Route::get('/', 'AdminUserController#getLogin');
Route::controller('page', 'AdminPageController');
Route::controller('user', 'AdminUserController');
Route::controller('menu', 'AdminMenuController');
});
Does anyone know how to do that ?
Thank you
Just figured out. You are missing a uses, and the second parameter should be an array.
Route::get('/', ['uses' => 'AdminUserController#getLogin']);