|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /var/www/flavourapps.com/leads/leads/app/Imports/ |
Upload File : |
<?php
namespace App\Imports;
use App\Models\Restaurant;
use App\Models\Role;
use Illuminate\Validation\ValidationException;
use Illuminate\Support\Facades\Hash;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
class RestaurantImport implements ToModel,WithHeadingRow
{
public function model(array $row)
{
$mainArray = array();
$rowArray = array(
"restaurant_name" => $row["restaurant_name"],
"restaurant_type" => $row["restaurant_type"],
"address" => $row["address"],
"mobile" => $row["mobile"],
"city" => $row["city"],
"district" => $row["district"],
"state" => $row["state"],
"country" => $row["country"],
"zip" => $row["zip"],
"contact_number" => $row["contact_number"],
"other_mobile" => $row["other_mobile"],
"manager_name" => $row["manager_name"],
"manager_mobile" => $row["manager_mobile"],
"manager_email" => $row["manager_email"],
"owner_name" => $row["owner_name"],
"owner_mobile" => $row["owner_mobile"],
"owner_email" => $row["owner_email"],
"no_of_branches" => $row["no_of_branches"],
"software_available" => $row["software_available"],
"software_name" => $row["software_name"],
"notes" => $row["notes"],
'created_at' => date('Y-m-d H:i:s')
);
array_push($mainArray,$rowArray);
//dd($mainArray);
foreach($mainArray as $user)
{
$user["other_mobile"] = json_encode($user["other_mobile"]);
$res = Restaurant::create($user);
}
}
}