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.
41 lines
1.2 KiB
41 lines
1.2 KiB
<?php
|
|
|
|
namespace App\Imports;
|
|
|
|
use App\Models\ParkingPattern;
|
|
use App\Services\OperationLogService;
|
|
use App\Services\ParkingPatternService;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Validation\ValidationException;
|
|
use Maatwebsite\Excel\Concerns\ToModel;
|
|
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|
|
|
class ParkingPatternImport implements ToModel, WithHeadingRow
|
|
{
|
|
protected string $model_name;
|
|
protected string $user_id;
|
|
|
|
public function __construct(string $model_name, string $user_id)
|
|
{
|
|
$this->model_name = $model_name;
|
|
$this->user_id = $user_id;
|
|
}
|
|
|
|
/**
|
|
* @param array $row
|
|
*/
|
|
public function model(array $row)
|
|
{
|
|
if (!empty($row['parking_space_no']) && !empty($row['parking_space_type'])) {
|
|
$data = [
|
|
'model_name' => $this->model_name,
|
|
'admin_user_id' => $this->user_id,
|
|
'parking_space_number' => $row['parking_space_no'],
|
|
'parking_space_type' => $row['parking_space_type']
|
|
];
|
|
$service = new ParkingPatternService(new OperationLogService());
|
|
$service->saveModel($data);
|
|
}
|
|
}
|
|
}
|
|
|