停车场管理系统
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.
 
 

32 lines
854 B

<?php
namespace App\Imports;
use App\Models\ParkingVipList;
use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
class ParkingVipListImport implements ToModel, WithHeadingRow
{
/**
* @param array $row
* @return ParkingVipList
*/
public function model(array $row): ParkingVipList
{
foreach ($row as $license) {
if (!ParkingVipList::query()->where('license', $license)
->exists()
) {
return new ParkingVipList([
'license' => $license,
'user_id' => Auth::guard('sanctum')->user()['id'],
'created_at' => get_datetime()
]);
}
break;
}
return new ParkingVipList();
}
}