|
|
|
@ -5,23 +5,28 @@ namespace App\Exports; |
|
|
|
use App\Models\AdminUsers; |
|
|
|
use App\Models\ParkingLicensePlate; |
|
|
|
use App\Models\ParkingVipList; |
|
|
|
use Illuminate\Database\Eloquent\Collection; |
|
|
|
use Maatwebsite\Excel\Concerns\FromCollection; |
|
|
|
use Maatwebsite\Excel\Concerns\FromArray; |
|
|
|
use Maatwebsite\Excel\Concerns\WithHeadings; |
|
|
|
|
|
|
|
class ParkingVipListExport implements FromCollection, WithHeadings |
|
|
|
class ParkingVipListExport implements FromArray, WithHeadings |
|
|
|
{ |
|
|
|
/** |
|
|
|
* @return Collection |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
public function collection(): Collection |
|
|
|
public function array(): array |
|
|
|
{ |
|
|
|
return ParkingVipList::all()->each(function ($item) { |
|
|
|
$item['license'] = ParkingLicensePlate::getNumber($item['license_id']); |
|
|
|
$item['user_id'] = AdminUsers::getUsername( |
|
|
|
$item['user_id'] |
|
|
|
); |
|
|
|
}); |
|
|
|
$list = ParkingVipList::all()->toArray(); |
|
|
|
$data = []; |
|
|
|
$index = 1; |
|
|
|
foreach ($list as $item) { |
|
|
|
$data[] = [ |
|
|
|
$index, |
|
|
|
ParkingLicensePlate::getNumber($item['license_id']), |
|
|
|
AdminUsers::getUsername($item['user_id']), |
|
|
|
]; |
|
|
|
$index += 1; |
|
|
|
} |
|
|
|
return $data; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|