mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
add export users module
This commit is contained in:
parent
5c5d11b1f2
commit
fd5dae0320
@ -5,5 +5,8 @@
|
|||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Visiosoft\\ProfileModule\\": "src/"
|
"Visiosoft\\ProfileModule\\": "src/"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"maatwebsite/excel": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,4 +14,5 @@ return [
|
|||||||
'go_user' => 'Go to User Detail',
|
'go_user' => 'Go to User Detail',
|
||||||
'personal' => 'Personal',
|
'personal' => 'Personal',
|
||||||
'corporate' => 'Corporate',
|
'corporate' => 'Corporate',
|
||||||
|
'export' => 'Export CSV',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
<?php namespace Visiosoft\ProfileModule\Http\Controller\Admin;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Visiosoft\ProfileModule\Profile\UsersExport;
|
||||||
|
|
||||||
|
class UsersController extends AdminController
|
||||||
|
{
|
||||||
|
public function exportUsers()
|
||||||
|
{
|
||||||
|
return Excel::download(new UsersExport(), 'users-' . time() . '.csv');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
<?php namespace Visiosoft\ProfileModule\Profile;
|
||||||
|
|
||||||
|
use Anomaly\UsersModule\User\User;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||||
|
|
||||||
|
class UsersExport implements WithMapping, FromCollection, WithHeadings
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return User[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection
|
||||||
|
*/
|
||||||
|
public function collection()
|
||||||
|
{
|
||||||
|
return User::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function map($user): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$user->email,
|
||||||
|
$user->username,
|
||||||
|
$user->first_name,
|
||||||
|
$user->last_name,
|
||||||
|
$user->display_name,
|
||||||
|
$user->ip_address,
|
||||||
|
$user->country_id,
|
||||||
|
$user->city,
|
||||||
|
$user->district,
|
||||||
|
$user->neighborhood,
|
||||||
|
$user->village,
|
||||||
|
$user->gsm_phone,
|
||||||
|
$user->land_phone,
|
||||||
|
$user->office_phone,
|
||||||
|
$user->phone_number,
|
||||||
|
$user->register_type,
|
||||||
|
$user->identification_number,
|
||||||
|
$user->created_at,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function headings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email address',
|
||||||
|
'username',
|
||||||
|
'first_name',
|
||||||
|
'last_name',
|
||||||
|
'display_name',
|
||||||
|
'ip_address',
|
||||||
|
'country_id',
|
||||||
|
'city',
|
||||||
|
'district',
|
||||||
|
'neighborhood',
|
||||||
|
'village',
|
||||||
|
'gsm_phone',
|
||||||
|
'land_phone',
|
||||||
|
'office_phone',
|
||||||
|
'phone_number',
|
||||||
|
'register_type',
|
||||||
|
'identification_number',
|
||||||
|
'created_at',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,9 @@
|
|||||||
<?php namespace Visiosoft\ProfileModule;
|
<?php namespace Visiosoft\ProfileModule;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Addon\AddonCollection;
|
||||||
use Anomaly\Streams\Platform\Addon\AddonServiceProvider;
|
use Anomaly\Streams\Platform\Addon\AddonServiceProvider;
|
||||||
|
use Maatwebsite\Excel\ExcelServiceProvider;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
|
use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
|
||||||
use Visiosoft\ProfileModule\Adress\AdressRepository;
|
use Visiosoft\ProfileModule\Adress\AdressRepository;
|
||||||
use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel;
|
use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel;
|
||||||
@ -133,6 +136,10 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
|||||||
'as' => 'visiosoft.module.profile::address_soft_delete',
|
'as' => 'visiosoft.module.profile::address_soft_delete',
|
||||||
'uses' => 'Visiosoft\ProfileModule\Http\Controller\AddressController@delete'
|
'uses' => 'Visiosoft\ProfileModule\Http\Controller\AddressController@delete'
|
||||||
],
|
],
|
||||||
|
'admin/users/export' => [
|
||||||
|
'as' => 'users::exportUsers',
|
||||||
|
'uses' => 'Visiosoft\ProfileModule\Http\Controller\Admin\UsersController@exportUsers'
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
// Cache links
|
// Cache links
|
||||||
@ -183,7 +190,7 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
|||||||
* @type array|null
|
* @type array|null
|
||||||
*/
|
*/
|
||||||
protected $aliases = [
|
protected $aliases = [
|
||||||
//'Example' => Visiosoft\ProfileModule\Example::class
|
'Excel' => Excel::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -218,7 +225,9 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
|||||||
*
|
*
|
||||||
* @type array|null
|
* @type array|null
|
||||||
*/
|
*/
|
||||||
protected $providers = [];
|
protected $providers = [
|
||||||
|
ExcelServiceProvider::class,
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The addon view overrides.
|
* The addon view overrides.
|
||||||
@ -252,10 +261,14 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
|||||||
/**
|
/**
|
||||||
* Boot the addon.
|
* Boot the addon.
|
||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot(AddonCollection $addonCollection)
|
||||||
{
|
{
|
||||||
// Run extra post-boot registration logic here.
|
$slug = 'export';
|
||||||
// Use method injection or commands to bring in services.
|
$section = [
|
||||||
|
'title' => 'visiosoft.module.profile::button.export',
|
||||||
|
'href' => route('users::exportUsers'),
|
||||||
|
];
|
||||||
|
$addonCollection->get('anomaly.module.users')->addSection($slug, $section);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user