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
832 B
32 lines
832 B
<?php |
|
|
|
namespace App\Imports; |
|
|
|
use App\Models\Type_peti; |
|
use Illuminate\Support\Collection; |
|
use Illuminate\Support\Facades\Auth; |
|
use Maatwebsite\Excel\Concerns\ToModel; |
|
use App\Models\Type_peti as ModelsType_peti; |
|
use Maatwebsite\Excel\Concerns\ToCollection; |
|
use Maatwebsite\Excel\Concerns\WithHeadingRow; |
|
|
|
class TipePetiImport implements ToModel, WithHeadingRow |
|
{ |
|
/** |
|
* @param array $row |
|
* |
|
* @return \Illuminate\Database\Eloquent\Model|null |
|
*/ |
|
public function model(array $row) |
|
{ |
|
// Mendapatkan informasi pengguna yang sedang login |
|
$user = Auth::user(); |
|
|
|
return new Type_peti([ |
|
'type' => $row['type'], |
|
'size_peti' => $row['size_peti'], |
|
'description' => $row['description'], |
|
'created_by' => $user->fullname, |
|
]); |
|
} |
|
}
|
|
|