I have some routes like this.
Route::prefix('bots')->group(function () {
Route::get('/', 'BotController@index')->name('bots');
Route::get('{bot_username}', 'BotController@edit');
...
});
what I want is in any way Inject a Bot model object to the second route in order to edit it.
so if we go to
mydomain.dev/bots/mybotusername
it should automatically call a custom method like findByUsername that I will define in a repository or a if possible in the bot model itself, and it will return a bot model object. in this model I should pass the route parameter bot_username and find and make an object and return it. so if it IS returning the object we can access the route to edit the object in BotController@edit and if returned null we cant access the route and show 404 error. is it possible?