Файловый менеджер - Редактировать - /home/easybachat/hisabat365.com/4a7891/laravel-datatables-fractal.tar
Ðазад
src/Transformers/FractalTransformer.php 0000644 00000004673 15060250074 0014341 0 ustar 00 <?php namespace Yajra\DataTables\Transformers; use Closure; use Illuminate\Support\Collection as LaravelCollection; use League\Fractal\Manager; use League\Fractal\Resource\Collection; use League\Fractal\Serializer\SerializerAbstract; use League\Fractal\TransformerAbstract; class FractalTransformer { protected Manager $fractal; /** * FractalTransformer constructor. */ public function __construct(Manager $fractal) { $this->fractal = $fractal; } /** * Transform output using the given transformer and serializer. */ public function transform( array|LaravelCollection $output, iterable $transformer, ?SerializerAbstract $serializer = null ): array { if ($serializer !== null) { $this->fractal->setSerializer($this->createSerializer($serializer)); } $collector = []; foreach ($transformer as $transform) { if ($transform != null) { $resource = new Collection($output, $this->createTransformer($transform)); $collection = $this->fractal->createData($resource)->toArray(); $transformed = $collection['data'] ?? $collection; $collector = array_map( function ($item_collector, $item_transformed) { if (! is_array($item_collector)) { $item_collector = []; } return array_merge($item_collector, $item_transformed); }, $collector, $transformed ); } } return $collector; } /** * Get or create transformer serializer instance. * * @param class-string|SerializerAbstract $serializer */ protected function createSerializer(SerializerAbstract|string $serializer): SerializerAbstract { if ($serializer instanceof SerializerAbstract) { return $serializer; } return new $serializer(); } /** * Get or create transformer instance. * * @param \Closure|class-string|TransformerAbstract $transformer */ protected function createTransformer(Closure|string|TransformerAbstract $transformer): Closure|TransformerAbstract { if ($transformer instanceof TransformerAbstract || $transformer instanceof Closure) { return $transformer; } return new $transformer(); } } src/Commands/stubs/transformer.inc.stub 0000644 00000001163 15060250074 0014245 0 ustar 00 <?php namespace DummyNamespace; use League\Fractal\TransformerAbstract; use App\Dummy; use App\Item; class DummyClass extends TransformerAbstract { protected $availableIncludes = ['item']; /** * @param \App\Dummy $dummy * @return array */ public function transform(Dummy $dummy): array { return [ 'id' => (int) $dummy->id, ]; } /** * @param \App\Dummy $dummy * @return \League\Fractal\Resource\Collection */ public function includeItem(Dummy $dummy) { return $this->collection($dummy->item, new ItemTransformer); } } src/Commands/stubs/transformer.stub 0000644 00000000520 15060250074 0013471 0 ustar 00 <?php namespace DummyNamespace; use League\Fractal\TransformerAbstract; use App\Dummy; class DummyClass extends TransformerAbstract { /** * @param \App\Dummy $dummy * @return array */ public function transform(Dummy $dummy): array { return [ 'id' => (int) $dummy->id, ]; } } src/Commands/TransformerMakeCommand.php 0000644 00000004353 15060250074 0014210 0 ustar 00 <?php namespace Yajra\DataTables\Commands; use Illuminate\Console\GeneratorCommand; use Illuminate\Support\Str; class TransformerMakeCommand extends GeneratorCommand { /** * The name and signature of the console command. * * @var string */ protected $signature = 'make:transformer {name : The name of the class} {include? : Name of the class to include.}'; /** * The console command description. * * @var string */ protected $description = 'Create a new Transformer Class'; /** * The type of class being generated. * * @var string */ protected $type = 'Transformer'; /** * Replace the class name for the given stub. * * @param string $stub Contents of the stub * @param string $name The class name */ protected function replaceClass($stub, $name): string { $stub = parent::replaceClass($stub, $name.'Transformer'); $stub = str_replace('Dummy', ucfirst($this->argument('name')), $stub); $stub = str_replace('dummy', lcfirst($this->argument('name')), $stub); if ($this->argument('include')) { $stub = str_replace('Item', ucfirst($this->argument('include')), $stub); $stub = str_replace('item', lcfirst($this->argument('include')), $stub); } return $stub; } /** * Get the stub file for the generator. */ protected function getStub(): string { return $this->argument('include') ? __DIR__.'/stubs/transformer.inc.stub' : __DIR__.'/stubs/transformer.stub'; } /** * Get the default namespace for the class. * * @param string $rootNamespace The root namespace */ protected function getDefaultNamespace($rootNamespace): string { return $rootNamespace.'\Transformers'; } /** * Get the destination class path. * * @param string $name Name of the class with namespace */ protected function getPath($name): string { $name = Str::replaceFirst($this->rootNamespace(), '', $name); return $this->laravel['path'].'/'.str_replace('\\', '/', $name).'Transformer.php'; } } src/FractalServiceProvider.php 0000644 00000005151 15060250074 0012455 0 ustar 00 <?php namespace Yajra\DataTables; use Illuminate\Support\ServiceProvider; use League\Fractal\Manager; use League\Fractal\Serializer\DataArraySerializer; use Yajra\DataTables\Commands\TransformerMakeCommand; use Yajra\DataTables\Transformers\FractalTransformer; class FractalServiceProvider extends ServiceProvider { /** * Bootstrap the application events. */ public function boot(): void { $this->mergeConfigFrom(__DIR__.'/../config/datatables-fractal.php', 'datatables-fractal'); $this->publishAssets(); $this->registerMacro(); } /** * Publish datatables assets. */ protected function publishAssets(): void { $this->publishes( [ __DIR__.'/../config/datatables-fractal.php' => config_path('datatables-fractal.php'), ], 'datatables-fractal' ); } /** * Register DataTables macro methods. */ protected function registerMacro(): void { DataTableAbstract::macro('setTransformer', function ($transformer) { $this->transformer = [$transformer]; return $this; }); DataTableAbstract::macro('addTransformer', function ($transformer) { $this->transformer[] = $transformer; return $this; }); DataTableAbstract::macro('setSerializer', function ($serializer) { $this->serializer = $serializer; return $this; }); } /** * Register the service provider. */ public function register(): void { $this->app->singleton('datatables.fractal', function () { $fractal = new Manager; $config = $this->app['config']; $request = $this->app['request']; $includesKey = $config->get('datatables-fractal.includes', 'include'); if ($request->get($includesKey)) { $fractal->parseIncludes($request->get($includesKey)); } $serializer = $config->get('datatables-fractal.serializer', DataArraySerializer::class); $fractal->setSerializer(new $serializer); return $fractal; }); $this->app->singleton('datatables.transformer', function () { return new FractalTransformer($this->app->make('datatables.fractal')); }); $this->commands([ TransformerMakeCommand::class, ]); } /** * Get the services provided by the provider. */ public function provides(): array { return [ 'datatables.fractal', 'datatables.transformer', ]; } } LICENSE.md 0000644 00000002117 15060250074 0006150 0 ustar 00 (The MIT License) Copyright (c) 2013-2018 Arjay Angeles <aqangeles@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. CHANGELOG.md 0000644 00000000663 15060250074 0006361 0 ustar 00 # Laravel DataTables Fractal Plugin ## Changelog ### v11.0.0 - 2024-03-14 - Add support for Laravel 11 ### v10.0.0 - 2023-02-07 - Add support for Laravel 10 ### v9.1.0 - 2022-06-20 - Update league/fractal to latest version #30 ### v9.0.0 - 2022-05-07 - Add support for Laravel 9 - Fix https://github.com/yajra/laravel-datatables-fractal/issues/27 - Add phpstan static analysis - Bump major version to match with the framework composer.json 0000644 00000001642 15060250074 0007270 0 ustar 00 { "name": "yajra/laravel-datatables-fractal", "description": "Laravel DataTables Fractal Plugin.", "keywords": [ "laravel", "datatables", "fractal", "api" ], "license": "MIT", "authors": [ { "name": "Arjay Angeles", "email": "aqangeles@gmail.com" } ], "require": { "php": "^8.2", "yajra/laravel-datatables-oracle": "^11.0", "league/fractal": "^0.20.1" }, "require-dev": { "nunomaduro/larastan": "^2.9.2", "orchestra/testbench": "^9" }, "autoload": { "psr-4": { "Yajra\\DataTables\\": "src/" } }, "autoload-dev": { "psr-4": { "Yajra\\DataTables\\Fractal\\Tests\\": "tests/" } }, "extra": { "branch-alias": { "dev-master": "11.x-dev" }, "laravel": { "providers": [ "Yajra\\DataTables\\FractalServiceProvider" ] } }, "minimum-stability": "dev", "prefer-stable": true } config/datatables-fractal.php 0000644 00000000362 15060250074 0012240 0 ustar 00 <?php return [ /* * Request key name to parse includes on fractal. */ 'includes' => 'include', /* * Default fractal serializer. */ 'serializer' => League\Fractal\Serializer\DataArraySerializer::class, ]; README.md 0000644 00000005073 15060250074 0006027 0 ustar 00 # Laravel DataTables Fractal Plugin [](http://laravel.com) [](https://packagist.org/packages/yajra/laravel-datatables-fractal) [](https://travis-ci.org/yajra/laravel-datatables-fractal) [](https://scrutinizer-ci.com/g/yajra/laravel-datatables-fractal/?branch=master) [](https://packagist.org/packages/yajra/laravel-datatables-fractal) [](https://packagist.org/packages/yajra/laravel-datatables-fractal) This package is a plugin of [Laravel DataTables](https://github.com/yajra/laravel-datatables) for transforming server-side response using [Fractal](https://github.com/thephpleague/fractal). ## Requirements - [PHP >= 8.2](http://php.net/) - [Laravel 11.x](https://github.com/laravel/framework) - [Laravel DataTables](https://github.com/yajra/laravel-datatables) ## Documentations - [Laravel DataTables Fractal Documentation](https://yajrabox.com/docs/laravel-datatables/master/response-fractal) ## Laravel Version Compatibility | Laravel | Package | |:--------------|:--------| | 8.x and below | 1.x | | 9.x | 9.x | | 10.x | 10.x | | 11.x | 11.x | ## Quick Installation `composer require yajra/laravel-datatables-fractal:^11.0` ### Register Service Provider (Optional on Laravel 5.5+) `Yajra\DataTables\FractalServiceProvider::class` ### Configuration and Assets (Optional) `$ php artisan vendor:publish --tag=datatables-fractal --force` And that's it! Start building out some awesome DataTables! ## Contributing Please see [CONTRIBUTING](https://github.com/yajra/laravel-datatables-fractal/blob/master/.github/CONTRIBUTING.md) for details. ## Security If you discover any security related issues, please email [aqangeles@gmail.com](mailto:aqangeles@gmail.com) instead of using the issue tracker. ## Credits - [Arjay Angeles](https://github.com/yajra) - [All Contributors](https://github.com/yajra/laravel-datatables-fractal/graphs/contributors) ## License The MIT License (MIT). Please see [License File](https://github.com/yajra/laravel-datatables-fractal/blob/master/LICENSE.md) for more information.
| ver. 1.4 |
Github
|
.
| PHP 8.2.29 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка