I'm trying to implement import from XLS file to Orders table in my Laravel project with SQL server database. For this purpose I use Laravel Excell package: https://laravel-excel.maatwebsite.nl/ .
I get following error while trying to test an upload:
PDOException (25000)
SQLSTATE[25000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot >>roll back trans2. No transaction or savepoint of that name was found.
The code line with importing is this:
Excel::import(new OrdersImport, $request->file('file'));
The code for OrdersImport is this:
class OrdersImport implements ToModel, WithHeadingRow
{
/**
* @param array $row
*
* @return \Illuminate\Database\Eloquent\Model|null
*/
public function model(array $row)
{
return new Order([
'name' => $row['name'],
'due_date' => $row['due_date'],
'quantity' => $row['quantity'],
'id_item' => $row['id_item'],
'id_client' => $row['id_client'],
]);
}
}
Any ideas what to do?