├── .github └── FUNDING.yml ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── art └── screenshot.png ├── composer.json ├── docs └── .gitkeep ├── src ├── .DS_Store ├── Commands │ └── ExcelGenerator.php └── FilamentExcelProvider.php └── templates └── actions.blade.php /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [3x1io] 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3x1io/filament-excel/1084b37bdeac239fdadf88767729300956d0eca7/CHANGELOG.md -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright 2022 info@3x1.io 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Screenshot of Login](./art/screenshot.png) 2 | 3 | # Filament Excel Export 4 | 5 | Excel Export for Resources 6 | 7 | ## Installation 8 | 9 | You can install the package via composer: 10 | 11 | ```bash 12 | composer require 3x1io/filament-excel 13 | ``` 14 | 15 | and now clear cache 16 | 17 | ```bash 18 | php artisan optimize:clear 19 | ``` 20 | 21 | ## Usage 22 | 23 | it's very easy to generate export just use this command 24 | 25 | ```bash 26 | php artisan filament:export UserResource User 27 | ``` 28 | 29 | where `UserResource` is a Resource name and `User` is a Model 30 | 31 | ## Changelog 32 | 33 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 34 | 35 | ## Credits 36 | 37 | - [Fady Mondy](https://github.com/3x1io) 38 | 39 | ## License 40 | 41 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 42 | -------------------------------------------------------------------------------- /art/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3x1io/filament-excel/1084b37bdeac239fdadf88767729300956d0eca7/art/screenshot.png -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "3x1io/filament-excel", 3 | "description": "Excel Export for Resources", 4 | "keywords": [ 5 | "laravel", 6 | "excel", 7 | "import", 8 | "export", 9 | "ui", 10 | "filament" 11 | ], 12 | "homepage": "https://3x1.io", 13 | "license": "MIT", 14 | "autoload": { 15 | "psr-4": { 16 | "io3x1\\FilamentExcel\\": "src/" 17 | } 18 | }, 19 | "authors": [ 20 | { 21 | "name": "3x1", 22 | "email": "info@3x1.io", 23 | "role": "CEO" 24 | } 25 | ], 26 | "minimum-stability": "dev", 27 | "require": { 28 | "php": "^8.0", 29 | "filament/filament": "^2.9", 30 | "maatwebsite/excel": "^3.1", 31 | "spatie/laravel-package-tools": "^1.10" 32 | }, 33 | "config": { 34 | "sort-packages": true 35 | }, 36 | "extra": { 37 | "laravel": { 38 | "providers": [ 39 | "io3x1\\FilamentExcel\\FilamentExcelProvider" 40 | ] 41 | } 42 | }, 43 | "prefer-stable": true 44 | } 45 | -------------------------------------------------------------------------------- /docs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3x1io/filament-excel/1084b37bdeac239fdadf88767729300956d0eca7/docs/.gitkeep -------------------------------------------------------------------------------- /src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3x1io/filament-excel/1084b37bdeac239fdadf88767729300956d0eca7/src/.DS_Store -------------------------------------------------------------------------------- /src/Commands/ExcelGenerator.php: -------------------------------------------------------------------------------- 1 | argument('resource'); 44 | $modelName = $this->argument('model'); 45 | 46 | //Get Resources File 47 | $resourcesPath = app_path('Filament/Resources/' . $resourceName . '.php'); 48 | $modelPath = app_path('Models/' . $modelName . '.php'); 49 | //Check if Resources Exist 50 | if (File::exists($resourcesPath)) { 51 | //Check if Model Exists 52 | if (File::exists($modelPath)) { 53 | $pluralModelName = Str::plural($modelName); 54 | 55 | //Generate Export 56 | Artisan::call('make:export ' . $pluralModelName . 'Export --model=' . $modelName); 57 | $this->info('The Export Class Has Generated'); 58 | 59 | //Add Action To List Page For Import & Export 60 | $getFileContent = view('filament-excel-templates::actions', [ 61 | "resource" => $resourceName, 62 | "model" => $modelName, 63 | "pluralModelName" =>$pluralModelName, 64 | ]); 65 | 66 | 67 | $listResourcePath = app_path('Filament/Resources/' . $resourceName . '/Pages/List' . $pluralModelName . '.php'); 68 | if (File::exists($listResourcePath)) { 69 | File::put($listResourcePath, $getFileContent); 70 | 71 | $this->info('The The Resource Class Has Updated'); 72 | 73 | //TODO START Import Excel 74 | } else { 75 | $this->error('Can Not Found ListResources Path'); 76 | } 77 | } else { 78 | $this->error('Sorry This Model Is Not Exist!'); 79 | } 80 | } else { 81 | $this->error('Sorry This Resources Is Not Exist!'); 82 | } 83 | 84 | 85 | return Command::SUCCESS; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/FilamentExcelProvider.php: -------------------------------------------------------------------------------- 1 | name('filament-excel'); 20 | } 21 | 22 | public function boot(): void 23 | { 24 | 25 | if ($this->app->runningInConsole()) { 26 | $this->commands([ 27 | ExcelGenerator::class, 28 | ]); 29 | } 30 | 31 | $this->loadViewsFrom(__DIR__ . '/../templates', 'filament-excel-templates'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /templates/actions.blade.php: -------------------------------------------------------------------------------- 1 | @php echo 'button() 22 | ->action('export'), 23 | ]); 24 | } 25 | 26 | public function export() 27 | { 28 | return Excel::download(new {{ $pluralModelName }}Export, '{{ Str::lower($pluralModelName) }}.xlsx'); 29 | } 30 | } 31 | --------------------------------------------------------------------------------