]> _ Git - psq.git/commitdiff
export users
authorLouis Jeckel <louis.jeckel@outlook.com>
Wed, 7 Apr 2021 10:19:57 +0000 (12:19 +0200)
committerLouis Jeckel <louis.jeckel@outlook.com>
Wed, 7 Apr 2021 10:19:57 +0000 (12:19 +0200)
app/Nova/Actions/ExportUsersToExcel.php [new file with mode: 0644]
app/Nova/User.php
composer.json
composer.lock

diff --git a/app/Nova/Actions/ExportUsersToExcel.php b/app/Nova/Actions/ExportUsersToExcel.php
new file mode 100644 (file)
index 0000000..33857dc
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+namespace App\Nova\Actions;
+
+use App\User;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Support\Collection;
+use Laravel\Nova\Actions\Action;
+use Laravel\Nova\Fields\ActionFields;
+use Maatwebsite\Excel\Concerns\WithHeadings;
+use Maatwebsite\Excel\Concerns\WithMapping;
+use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
+
+class ExportUsersToExcel extends DownloadExcel implements WithMapping, WithHeadings
+{
+
+    public $name = "Exporter vers Excel";
+    public $confirmButtonText = "Télécharger";
+    public $confirmText = "Export des utilisateurs vers Excel";
+
+    /**
+     * @param User $user
+     * @return array
+     */
+    public function map($user): array
+    {
+        return [
+            $user->first_name,
+            $user->last_name,
+            $user->email,
+            $user->address_line_1,
+            $user->city,
+            $user->postal_code,
+            $user->country,
+            $user->phone,
+            (string) $user->organization
+
+
+        ];
+    }
+
+    public function headings(): array
+    {
+        return [
+            'Prénom',
+            'Nom',
+            'Email',
+            'Adresse',
+            'Ville',
+            'Code Postal',
+            'Pays',
+            'Téléphone',
+            'Organisation'
+
+        ];
+    }
+
+}
index e2d013b580dfa91801d447d6ee430a99b219fd2c..f455fb965f7cd32504e74db6fb5152c85236792b 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\Nova;
 
 use App\MailgunEvent;
+use App\Nova\Actions\ExportUsersToExcel;
 use App\Nova\Actions\ImportUsers;
 use App\Nova\Actions\SendCustomNotification;
 use App\Nova\Actions\SendNotification;
@@ -38,6 +39,7 @@ use Laravel\Nova\Fields\Text;
 use Laravel\Nova\Http\Requests\NovaRequest;
 use Laravel\Nova\Panel;
 use Laravel\Nova\Tests\Fixtures\Profile;
+use Maatwebsite\LaravelNovaExcel\Actions\DownloadExcel;
 
 class User extends Resource
 {
@@ -202,6 +204,7 @@ class User extends Resource
     public function actions(Request $request)
     {
         return array_merge([
+            new ExportUsersToExcel,
             new ImportUsers,
             new SendNotification,
             new StartTrial,
index 58e7a5a1d17ea9cb9f44b827be2b4df96414f258..023bcef8d7ba159dcb880a093f1980043b7a32df 100644 (file)
@@ -36,6 +36,7 @@
         "league/glide": "^1.5",
         "league/glide-laravel": "^1.0",
         "league/html-to-markdown": "^4.9",
+        "maatwebsite/laravel-nova-excel": "^1.2",
         "mailgun/mailgun-php": "^3.0",
         "masterminds/html5": "^2.7",
         "numaxlab/nova-ckeditor5-classic": "^1.1",
index eea0e966d54ca1bb56641ac5cbf90d60b368acb2..8a1db8fb850bb2b9d0bb1ce320dc94dcd7cdf7e5 100644 (file)
@@ -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": "a63ddd7c0e259fef66125fa383140abb",
+    "content-hash": "8f33d2bbf6bc00c0cb50b2151651b430",
     "packages": [
         {
             "name": "algolia/algoliasearch-client-php",
             },
             "time": "2021-01-06T19:20:22+00:00"
         },
+        {
+            "name": "laravie/serialize-queries",
+            "version": "v0.2.3",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/laravie/serialize-queries.git",
+                "reference": "0b73889e102db6708d64ff003b028b42687ceeb4"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/laravie/serialize-queries/zipball/0b73889e102db6708d64ff003b028b42687ceeb4",
+                "reference": "0b73889e102db6708d64ff003b028b42687ceeb4",
+                "shasum": ""
+            },
+            "require": {
+                "illuminate/database": "^5.8 || ^6.0 || ^7.0 || ^8.0",
+                "illuminate/queue": "^5.8 || ^6.0 || ^7.0 || ^8.0",
+                "opis/closure": "^3.4.2",
+                "php": ">=7.1"
+            },
+            "require-dev": {
+                "orchestra/testbench": "^3.8 || ^4.0 || ^5.0 || ^6.0"
+            },
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.x-dev"
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Laravie\\SerializesQuery\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Mior Muhammad Zaki",
+                    "email": "crynobone@gmail.com"
+                }
+            ],
+            "description": "Serializable Laravel Query Builder",
+            "support": {
+                "issues": "https://github.com/laravie/serialize-queries/issues",
+                "source": "https://github.com/laravie/serialize-queries/tree/v0.2.3"
+            },
+            "funding": [
+                {
+                    "url": "https://paypal.me/crynobone",
+                    "type": "custom"
+                },
+                {
+                    "url": "https://liberapay.com/crynobone",
+                    "type": "liberapay"
+                }
+            ],
+            "time": "2020-10-25T04:39:37+00:00"
+        },
         {
             "name": "league/commonmark",
             "version": "1.5.7",
             ],
             "time": "2020-11-27T16:17:38+00:00"
         },
+        {
+            "name": "maatwebsite/laravel-nova-excel",
+            "version": "1.2.3",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/Maatwebsite/Laravel-Nova-Excel.git",
+                "reference": "12a696e53be79e0f212c089abaa5f248d74eeb13"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/Maatwebsite/Laravel-Nova-Excel/zipball/12a696e53be79e0f212c089abaa5f248d74eeb13",
+                "reference": "12a696e53be79e0f212c089abaa5f248d74eeb13",
+                "shasum": ""
+            },
+            "require": {
+                "laravel/nova": "*",
+                "laravie/serialize-queries": "^0.2",
+                "maatwebsite/excel": "^3.1",
+                "php": ">=7.1.0"
+            },
+            "type": "library",
+            "extra": {
+                "laravel": {
+                    "providers": [
+                        "Maatwebsite\\LaravelNovaExcel\\LaravelNovaExcelServiceProvider"
+                    ]
+                }
+            },
+            "autoload": {
+                "psr-4": {
+                    "Maatwebsite\\LaravelNovaExcel\\": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Patrick Brouwers",
+                    "email": "patrick@maatwebsite.nl"
+                }
+            ],
+            "description": "Supercharged Excel exports for Laravel Nova Resources",
+            "keywords": [
+                "PHPExcel",
+                "actions",
+                "laravel",
+                "laravel-nova",
+                "nova",
+                "phpspreadsheet"
+            ],
+            "support": {
+                "issues": "https://github.com/Maatwebsite/Laravel-Nova-Excel/issues",
+                "source": "https://github.com/Maatwebsite/Laravel-Nova-Excel/tree/1.2.3"
+            },
+            "time": "2020-10-08T14:10:40+00:00"
+        },
         {
             "name": "maennchen/zipstream-php",
             "version": "2.1.0",