data excel like image below:
i want to change value when upload data from Excel to MySQL
if the cell has the name 'UNSIL' then when stored in the database will change to number '1'
i have code for uploading data from Excel to MySQL on laravel
public function importExcel(Request $request) {
if($request->hasFile('import_file')) {
$path = $request->file('import_file')->getRealPath();
$data = Excel::load($path, function($reader) {})->get();
if(!empty($data) && $data->count()) {
foreach($data as $key => $value) {
$insert[] = ['nama_fakultas'=>$value->nama_fakultas,
'nama_universitas'=>$value->nama_universitas,
'keterangan'=>$value->keterangan
];
if($value->nama_universitas = 'UNSIL') {
$value->nama_universitas = '1';
}
}
if(!empty($insert)) {
DB::table('fakultas')->truncate($insert);
DB::table('fakultas')->insert($insert);
return redirect('fakultas');
}
}
}
return back();
}
in the code above contains the data upload command from excel to mysql, and when I want to change the value of the name 'UNSIL' to number 1 nothing happens
can anyone help me for solve this case?