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: Meta helper weight: 3

A little helper

When using collection links in your resource the code for adding these collection links can be quite confusing:

class UserResource extends JsonResource
{
    use Spatie\ResourceLinks\HasLinks;
    
    public static function collection($resource)
    {
        return parent::collection($resource)->additional([
            'meta' => [
                'links' => self::collectionLinks(UsersController::class)
             ],
         ]);
    }
}

That's why we've added a little helper which puts links immediately in the meta section of a resource collection:

class UserResource extends JsonResource
{
    use Spatie\ResourceLinks\HasLinks;
    use Spatie\ResourceLinks\HasMeta;
    
    public static function meta()
    {
        return [
            'links' => self::collectionLinks(UsersController::class)
        ];
    }
}

You can use this little helper by including the Spatie\ResourceLinks\HasMeta trait in your resource.

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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony