优化更新
This commit is contained in:
@@ -53,15 +53,21 @@ class DepartmentExport implements FromCollection, WithHeadings, WithMapping, Sho
|
||||
*/
|
||||
public function map($department): array
|
||||
{
|
||||
$parentName = '';
|
||||
if ($department->parent_id) {
|
||||
$parent = Department::find($department->parent_id);
|
||||
$parentName = $parent ? $parent->name : '';
|
||||
}
|
||||
|
||||
return [
|
||||
$department->id,
|
||||
$department->name,
|
||||
$department->parent_id ? Department::find($department->parent_id)?->name : '',
|
||||
$parentName,
|
||||
$department->leader,
|
||||
$department->phone,
|
||||
$department->sort,
|
||||
(int)$department->sort,
|
||||
$department->status == 1 ? '启用' : '禁用',
|
||||
$department->created_at ? $department->created_at->toDateTimeString() : '',
|
||||
$department->created_at ? (string)$department->created_at : '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user