����JFIF��x�x����'
Server IP : 66.29.137.217 / Your IP : 3.15.139.248 Web Server : LiteSpeed System : Linux premium294.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : gltevjme ( 1095) PHP Version : 7.0.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/gltevjme/cbt.bofirm.com/app/Imports/ |
Upload File : |
<?php namespace App\Imports; use App\Models\User; use Carbon\Carbon; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Hash; use Laravel\Fortify\Rules\Password; use Maatwebsite\Excel\Concerns\Importable; use Maatwebsite\Excel\Concerns\ToCollection; use Maatwebsite\Excel\Concerns\WithBatchInserts; use Maatwebsite\Excel\Concerns\WithChunkReading; use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\WithValidation; class UsersImport implements ToCollection, WithHeadingRow, WithBatchInserts, WithChunkReading, WithValidation { use Importable; private int $rows = 0; private string $now; public function __construct() { $this->now = Carbon::now()->toDateTimeString(); } /** * Import users from excel * * @param Collection $rows * @return void */ public function collection(Collection $rows) { foreach ($rows as $row) { ++$this->rows; User::create([ 'first_name' => $row['first_name'], 'last_name' => $row['last_name'], 'user_name' => $row['user_name'], 'email' => $row['email'], 'email_verified_at' => $row['email_verified'] == 'yes' ? $this->now : null, 'password' => Hash::make($row['password']), ])->assignRole($row['role']); } } public function rules(): array { return [ 'first_name' => ['required', 'string', 'max:60'], 'last_name' => ['required', 'string', 'max:60'], 'user_name' => ['required', 'string', 'max:60', 'unique:users'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => ['required', 'string', new Password()], 'role' => ['required'], ]; } public function batchSize(): int { return 100; } public function chunkSize(): int { return 100; } public function getRowCount(): int { return $this->rows; } }