PHP code example of sinemacula / laravel-resource-exporter
1. Go to this page and download the library: Download sinemacula/laravel-resource-exporter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sinemacula / laravel-resource-exporter example snippets
use SineMacula\Exporter\Facades\Exporter;
use App\Http\Resources\YourResource;
// Export an item as CSV
$csv = Exporter::format('csv')->exportItem(new YourResource($item));
// Export a collection as XML
$xml = Exporter::format('xml')->exportCollection(YourResource::collection($collection));
bash
php artisan vendor:publish --provider="SineMacula\Exporter\ExporterServiceProvider"