In our project, we would like to put import csv file(we're using maat/website). We would like to check if the corresponding values in the csv file are correct so that we can save it in our table.
Controller
public function importCSVVendorList(Request $request)
{
$data = $request->all();
$validator = Validator::make($data, [
'file' => 'required|mimes:csv'
]);
// dd($validator->fails());
//if validator fails
// if ($validator->fails()) {
// return false;
// }
$path = $request->file('file')->getRealPath();
$row_values = Excel::load($path)->get();
if($row_values->count() > 0)
{
foreach($row_values->toArray() as $key => $value)
{
if($key == 1)
{
dd($value);
}
// foreach($value as $row)
// {
// dd($row['code']);
// $vendor_lists = array(
// // 'Code' => $row['']
// );
// }
}
}
dd($path);
}
Value of my dd
Question: How do we check the values in the csv file?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire