What you are asking is impossible because you cannot create a method without name that takes an argument like
public function get($boardName); // Not working
So, let me propose you two solutions:
First one, accept to have one more segment in your URL (http://host/boards/by-name/my-first-board) so that you can easily create a method getByName() in your controller. I just tested that and it works perfect:
<?php
class BoardController extends Controller {
public function getIndex(){
// Some stuff
}
public function getByName($name='defaultName'){
echo "By name: $name";
}
}
Second one, if you absolutely want that URL, use a classic routing method in your routes.php file. For example:
Route::get('boards/{name}', 'BoardController@someMethod');
It's up to you... :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community