From b06f40416d0c163d4bf245e3ea52bd17318df29d Mon Sep 17 00:00:00 2001 From: omaralalwisalla Date: Sun, 14 Nov 2021 01:33:33 +0300 Subject: [PATCH] add spatie fractal api package --- README.md | 3 +- composer.json | 1 + composer.lock | 143 ++++++++++++++++++++++++++++++++++++++++++++- config/fractal.php | 42 +++++++++++++ 4 files changed, 186 insertions(+), 3 deletions(-) create mode 100644 config/fractal.php diff --git a/README.md b/README.md index b84a6a7..f93ec32 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ It is a modular application, and a number of modules are installed by default. I * with Spatie Media Library and conversitions * with [Yajra DataTables](https://github.com/yajra/laravel-datatables) * with [infyom Laravel Generator](https://github.com/InfyOmLabs/laravel-generator) +* with [laravel fractal](https://github.com/spatie/laravel-fractal) * All Stubs are ready to customize * Notifications for Admin @@ -194,4 +195,4 @@ OR Contact by [ Email ](mailto:Contact@omaralalwi.info) ## License -This Project is open sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). \ No newline at end of file +This Project is open sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/composer.json b/composer.json index f5b19d9..285cf9e 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,7 @@ "spatie/laravel-activitylog": "^3.16", "spatie/laravel-backup": "^6.11", "spatie/laravel-feed": "^2.7", + "spatie/laravel-fractal": "^5.8", "spatie/laravel-html": "^2.28", "spatie/laravel-medialibrary": "^9.0.0", "spatie/laravel-permission": "^3.17", diff --git a/composer.lock b/composer.lock index 9ca9a70..fedfd20 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "71749e6e5c532bf871910c318f40b74a", + "content-hash": "553091651d7dc687bb5c9e8c5cc392c5", "packages": [ { "name": "alexusmai/laravel-file-manager", @@ -6627,6 +6627,67 @@ ], "time": "2021-01-25T08:24:04+00:00" }, + { + "name": "spatie/fractalistic", + "version": "2.9.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/fractalistic.git", + "reference": "c4fc2b223a8f7321ece449abc2c59cc5baf470fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/fractalistic/zipball/c4fc2b223a8f7321ece449abc2c59cc5baf470fd", + "reference": "c4fc2b223a8f7321ece449abc2c59cc5baf470fd", + "shasum": "" + }, + "require": { + "league/fractal": "^0.19.0", + "php": "^7.3|^8.0" + }, + "require-dev": { + "illuminate/pagination": "~5.3.0|~5.4.0", + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Fractalistic\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "A developer friendly wrapper around Fractal", + "homepage": "https://github.com/spatie/fractalistic", + "keywords": [ + "api", + "fractal", + "fractalistic", + "spatie", + "transform" + ], + "support": { + "issues": "https://github.com/spatie/fractalistic/issues", + "source": "https://github.com/spatie/fractalistic/tree/2.9.1" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2020-11-12T18:19:10+00:00" + }, { "name": "spatie/image", "version": "1.10.1", @@ -7009,6 +7070,84 @@ ], "time": "2020-09-08T22:07:43+00:00" }, + { + "name": "spatie/laravel-fractal", + "version": "5.8.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-fractal.git", + "reference": "be3ccd54e26742cd05b3637fb732fd9addfa28df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-fractal/zipball/be3ccd54e26742cd05b3637fb732fd9addfa28df", + "reference": "be3ccd54e26742cd05b3637fb732fd9addfa28df", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^7.0|^8.0", + "illuminate/support": "^7.0|^8.0", + "php": "^7.2|^8.0", + "spatie/fractalistic": "^2.5" + }, + "require-dev": { + "ext-json": "*", + "orchestra/testbench": "^5.0|^6.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\Fractal\\FractalServiceProvider" + ], + "aliases": { + "Fractal": "Spatie\\Fractal\\FractalFacade" + } + } + }, + "autoload": { + "psr-4": { + "Spatie\\Fractal\\": "src" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "An easy to use Fractal integration for Laravel applications", + "homepage": "https://github.com/spatie/laravel-fractal", + "keywords": [ + "api", + "fractal", + "laravel", + "laravel-fractal", + "lumen", + "spatie", + "transform" + ], + "support": { + "issues": "https://github.com/spatie/laravel-fractal/issues", + "source": "https://github.com/spatie/laravel-fractal/tree/5.8.1" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + } + ], + "time": "2020-11-12T18:46:53+00:00" + }, { "name": "spatie/laravel-html", "version": "2.28.1", @@ -13632,5 +13771,5 @@ "php": "^7.3.0" }, "platform-dev": [], - "plugin-api-version": "2.0.0" + "plugin-api-version": "2.1.0" } diff --git a/config/fractal.php b/config/fractal.php new file mode 100644 index 0000000..edc4337 --- /dev/null +++ b/config/fractal.php @@ -0,0 +1,42 @@ + '', + + /* The default paginator to be used when performing a transformation. It + * may be left empty to use Fractal's default one. This can either be a + * string or a League\Fractal\Paginator\PaginatorInterface subclass. + */ + 'default_paginator' => '', + + /* + * League\Fractal\Serializer\JsonApiSerializer will use this value + * as a prefix for generated links. Set to `null` to disable this. + */ + 'base_url' => null, + + /* + * If you wish to override or extend the default Spatie\Fractal\Fractal + * instance provide the name of the class you want to use. + */ + 'fractal_class' => Spatie\Fractal\Fractal::class, + + 'auto_includes' => [ + + /* + * If enabled Fractal will automatically add the includes who's + * names are present in the `include` request parameter. + */ + 'enabled' => true, + + /* + * The name of key in the request to where we should look for the includes to include. + */ + 'request_key' => 'include', + ], +];