停车场管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

39 lines
992 B

<?php
namespace App\Imports;
use App\Services\OperationLogService;
use App\Services\ParkingPatternService;
use Maatwebsite\Excel\Concerns\ToModel;
class ParkingPatternSpaceImport implements ToModel
{
protected string $user_id;
protected int $index = 1;
public function __construct(string $user_id)
{
$this->user_id = $user_id;
}
/**
* @param array $row
*/
public function model(array $row)
{
if ($this->index == 1) {
$this->index += 1;
return;
}
if (!empty($row[1]) && !empty($row[2]) && !empty($row[3])) {
$data = [
'model_name' => $row[1],
'admin_user_id' => $this->user_id,
'parking_space_number' => $row[2],
'parking_space_type' => $row[3]
];
$service = new ParkingPatternService(new OperationLogService());
$service->saveModel($data);
}
}
}