bencepentek's avatar

bencepentek liked a comment+100 XP

5mos ago

Probably the best API video ever seen.

bencepentek's avatar

bencepentek liked a comment+100 XP

5mos ago

@Bionik6 thanks but this is not working in my test, because the last withRouting() overwrite the previous. I have found this solution:

->withRouting(
        web: __DIR__.'/../routes/web.php',
        api: __DIR__.'/../routes/api.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
        then: function () {
            Route::middleware('api')
                ->prefix('api/v1')
                ->group(__DIR__.'/../routes/api_v1.php');
        }
bencepentek's avatar

bencepentek liked a comment+100 XP

5mos ago

@Bionik6 my solution with Laravel 11 bootstrap/app.php file:

...
return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        api: [// <-- we can use an array here
            __DIR__.'/../routes/api.php',
            __DIR__.'/../routes/api_v1.php',
        ],
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
...

and inside api_v1.php file:

...
Route::prefix('v1')->group(function () {
    Route::apiResource('tickets', \App\Http\Controllers\Api\V1\TicketController::class);
});
...
bencepentek's avatar

bencepentek liked a comment+100 XP

5mos ago

In Laravel 11, you'll load the custom api_v1.php file in booststrap/app.php, and it will look like this:

return Application::configure(basePath: dirname(__DIR__))
    ...
    ->withRouting(
        api: __DIR__.'/../routes/api_v1.php',
        apiPrefix: 'api/v1',
    )
	...
bencepentek's avatar

bencepentek wrote a reply+100 XP

5mos ago

Fixed it, thanks!

bencepentek's avatar

bencepentek liked a comment+100 XP

5mos ago

This will be resolved in PHP Storm when you Cmd-Shift-. every time after a migration or model change. It will generate Laravel Idea Helper Code that will help the IDE to understand your Laravel app code.

bencepentek's avatar

bencepentek liked a comment+100 XP

5mos ago

If you're working along, you can download the form-specific components that I referenced at the beginning of the video here: https://github.com/laracasts/pixel-position/tree/main/resources/views/components/forms

bencepentek's avatar

bencepentek liked a comment+100 XP

5mos ago

Use this instead of the link in the video, if it's not working: https://placehold.co/42x42

bencepentek's avatar

bencepentek wrote a comment+100 XP

5mos ago

Use this instead of the link in the video, if it's not working: https://placehold.co/42x42