Support the ongoing development of Laravel.io →
Configuration Requests Architecture
Last updated 2 years ago.
0

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... :)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

dhuzz dhuzz Joined 5 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.