0
votes

I've been stuck with a problem in Laravel 5.

Question: Is is possible to have a default function in a Laravel controller if no other functions are activated?

Explanation:

In routes I have this:

Route::controllers([
    'auth' => 'Auth\AuthController',
    'password' => 'Auth\PasswordController',
    '/projects' => 'ProjectController'
]);

By doing this I can call functions in my ProjectController like getIndex or postCreate. I'd like to have the following /projects/create, /projects/edit/{id} etc. AND /projects/{slug} <- name of project. Before, when I set all my routes individually I could just place the /projects/{slug} at the bottom and it would check for that at last.

I thought of a solution: go trough all the functions, if none of them are executed do the default function (for /projects/{slug})

How would I do this? If more code is needed, please ask! :)

1

1 Answers

2
votes

I think you might be looking for missingMethod:

public function missingMethod($parameters = array())
{
    // code goes here
}

Read more in the Laravel Documentation.