Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Endpoint Resources Laravel Package

spatie/laravel-endpoint-resources

Abandoned package that adds controller/action-based URL links to Laravel API resources and collection meta. Includes traits to generate “show/edit/update/delete” item links and “index/create/store” collection links automatically.

View on GitHub
Deep Wiki
Context7

title: Controllers weight: 2

A controller can be added to an link group as such:

class UserResource extends JsonResource
{
    use HasLinks;

    public function toArray($request)
    {
        return [
            'links' => $this->links(function (Links $links) {
                $links->controller(UsersController::class);
            }),
        ];
    }
}

It is possible to specify the parameters for the links:

$links
    ->controller(UsersController::class)
    ->parameters(User::first());

Or prefix all the links of the controller:

$links
    ->controller(UsersController::class)
    ->prefix('admin');

This will produce the following JSON:

"links": {
    "admin.show": "https://laravel.app/admin/users/1",
    "admin.edit": "https://laravel.app/admin/users/1/edit"
}

You can also choose the methods of the controller to include as links:

$links
    ->controller(UsersController::class)
    ->methods(['create', 'index', 'show']);

Or even alias the name of methods:

$links
    ->controller(UsersController::class)
    ->names(['index' => 'list']);

This will produce the following JSON:

"links": {
    "list": "https://laravel.app/admin/users"
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai