30 lines
757 B
PHP
30 lines
757 B
PHP
<?php
|
|
|
|
namespace App\Imports;
|
|
|
|
use App\Models\ImportApplyUser;
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
|
|
|
class ApplyUserImport implements \Maatwebsite\Excel\Concerns\ToArray
|
|
{
|
|
|
|
protected $activity_id;
|
|
public function __construct($activity_id)
|
|
{
|
|
$this->activity_id = $activity_id;
|
|
}
|
|
|
|
public function array(array $rows)
|
|
{
|
|
foreach ($rows as $row) {
|
|
Log::info($row);
|
|
$name = $row[0];
|
|
$mobile = $row[1];
|
|
if ($name == "名称" && $mobile == "手机号") continue;
|
|
ImportApplyUser::updateOrCreate(['activity_id'=>$this->activity_id, 'mobile'=>$mobile], ['name'=>$name]);
|
|
}
|
|
}
|
|
}
|