feat: inisialisasi project kit v2
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Imports;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithValidation;
|
||||
|
||||
class UsersImport implements ToModel, WithHeadingRow, WithValidation
|
||||
{
|
||||
public function model(array $row)
|
||||
{
|
||||
return new User([
|
||||
'first_name' => $row['first_name'],
|
||||
'last_name' => $row['last_name'],
|
||||
'email' => $row['email'],
|
||||
'status' => $row['status'] ?? 'active',
|
||||
'password' => Hash::make($row['password'] ?? 'password123'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'first_name' => 'required|string|max:255',
|
||||
'last_name' => 'required|string|max:255',
|
||||
'email' => 'required|email|unique:users,email',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user