6 changed files with 138 additions and 42 deletions
@ -0,0 +1,58 @@ |
|||
<?php |
|||
|
|||
namespace App\Exports; |
|||
|
|||
use App\Models\ParkingCamera; |
|||
use App\Services\OperationLogService; |
|||
use App\Services\ParkingCameraService; |
|||
use Maatwebsite\Excel\Concerns\FromArray; |
|||
use Maatwebsite\Excel\Concerns\WithHeadings; |
|||
|
|||
class ParkingCameraExport implements FromArray, WithHeadings |
|||
{ |
|||
public function array(): array |
|||
{ |
|||
$data = []; |
|||
$index = 1; |
|||
ParkingCamera::all()->each( |
|||
function ($item) use (&$data, &$index) { |
|||
$oldItem = (new ParkingCameraService( |
|||
new OperationLogService() |
|||
))->optionItems($item); |
|||
$data[] = [ |
|||
'id' => $index, |
|||
'floor' => $oldItem['floor'], |
|||
'number' => $oldItem['number'], |
|||
'camera_ip' => $oldItem['camera_ip'], |
|||
'parking_space_count' => $oldItem['parking_space_count'], |
|||
'parking_space_numbers' => $oldItem['parking_space_numbers'], |
|||
'is_control_lights' => $oldItem['is_control_lights'], |
|||
'type' => $oldItem['type'], |
|||
'status' => $oldItem['status'], |
|||
'updated_at' => $oldItem['updated_at'] |
|||
]; |
|||
$index += 1; |
|||
} |
|||
); |
|||
return $data; |
|||
} |
|||
|
|||
/** |
|||
* @return array |
|||
*/ |
|||
public function headings(): array |
|||
{ |
|||
return [ |
|||
__('exports.global.index'), |
|||
__('exports.parking_space.floor'), |
|||
__('exports.parking_camera.number'), |
|||
__('exports.parking_camera.camera_ip'), |
|||
__('exports.parking_camera.parking_space_count'), |
|||
__('exports.parking_camera.parking_space_numbers'), |
|||
__('exports.parking_camera.is_control_lights'), |
|||
__('exports.parking_camera.type'), |
|||
__('exports.parking_camera.status'), |
|||
__('exports.parking_camera.updated_at') |
|||
]; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue