FarmerExporter.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
+-----------------------------------------------------------------------------------------------------------------------
* 导出类:Farmer
+-----------------------------------------------------------------------------------------------------------------------
*
* PHP version 7
*
* @category App\Admin\Extensions\Exporter
* @package App\Admin\Extensions\Exporter
* @author Richer <yangzi1028@163.com>
* @date 2023年2月17日09:59:18
* @copyright 2021-2022 Richer (http://www.Richer.com/)
* @license http://www.Richer.com/ License
* @link http://www.Richer.com/
*/
namespace App\Admin\Extensions\Exporter;
use App\Admin\Extensions\CustomExporter;
use Maatwebsite\Excel\Concerns\WithMapping;
/**
* Class FarmerExporter
* @package App\Admin\Extensions\Exporter
*/
class FarmerExporter extends CustomExporter implements WithMapping
{
protected $columns = [
'id' => '序号',
'group_id' => '所属小组',
'family_id' => '所属家庭',
'nickname' => '微信昵称',
// 'avatar' => '头像',
'name' => '姓名',
'mobile' => '手机号码',
'gender' => '性别',
'role' => '角色',
'house_number' => '门牌号',
'address' => '详细地址',
'login_times' => '登录次数',
'last_login_time' => '上次登录时间',
'created_at' => '注册时间',
];
/**
* 字段映射
*
* @param $model
* @return array
*/
public function map($model) : array
{
ini_set("memory_limit", "-1");
$this->index ++ ;
// 返回的映射数组
return [
$this->index,
optional($model->group)->name,
optional($model->family)->name,
$model->nickname,
$model->name,
"".$model->mobile,
$model->gender_show,
$model->role_show,
$model->house_number,
$model->address,
$model->login_times,
$model->last_login_time,
$model->created_at,
];
}
}