weward / laramacro
A set of custom macros for Laravel
v10.0.1
2023-12-25 04:03 UTC
Requires
- php: ^8.1
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- larastan/larastan: ^2.0.1
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.20
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
This package is auto-updated.
Last update: 2025-03-25 06:54:13 UTC
README
A set of custom macros for Laravel
Table of Contents
Installation
You can install the package via composer:
# for the meantime
composer require weward/laramacro:dev-master
Publish Service Provider
php artisan vendor:publish --tag=laramacro-providers
You may register the service srovider at config/app.php
'providers' => [ // ... App\Providers\LaraMacroServiceProvider::class, ]
Usage
Response Macro
jsonApi()
A superset of ->json()
response format that can accept Laravel Resource
payload.
// Pass normal payload and http status return response()->jsonApi($data, 200); // Pass a Resource and hhtp status return response()->jsonApi(new UserResource($data), 200);
Credits
License
The MIT License (MIT). Please see License File for more information.