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 Resource Endpoints Laravel Package

spatie/laravel-resource-endpoints

Abandoned package that adds controller-based “links” and collection “meta” links to Laravel API Resources. Automatically generates URLs for actions like index/show/edit/update/delete, so resources can expose REST endpoints without manually building routes.

View on GitHub
Deep Wiki
Context7

title: Action links weight: 2

Sometimes you want to add links not belonging to a specific controller. Then it is possible to add an action as an link. They look just like a standard Laravel action:

class OtherResource extends JsonResource
{
    use HasLinks;

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

The HTTP verb for the action will be resolved from the route in Laravel. Should you have an action with two verbs, then you can always specify the verb for a particular action:

class OtherResource extends JsonResource
{
    use HasLinks;

    public function toArray($request)
    {
        $user = Auth::user();

        return [
            'links' => $this->links()
                ->action([UsersController::class, 'update'], [], 'PUT'),
        ];
    }
}

Of course, it is also possible to use this with collection links:

class UserResource extends JsonResource
{
    use HasLinks;

    public static function collection($resource)
    {
        return parent::collection($resource)->additional([
            'meta' => [
                'links' => self::collectionLinks(UsersController::class)
                    ->action([UsersController::class, 'update'], [], 'PUT'),
             ],
         ]);
    }
}
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