Part of my command in laravel is failing due to a fatal error:
cannot use object of type stdClass as array
I know it has to do with the following code block, because it truncates the table but it fails on inserting new records for each row/result. Skus is a model with all the fields set as fillable.
Why would it be failing here with that error?
if ($results) {
Skus::truncate();
foreach ($results as $row) {
$sku = new Skus;
$sku->category = $row['category'];
$sku->build = $row['build'];
$sku->fabric = $row['fabric'];
$sku->color = $row['color'];
$sku->location = $row['location'];
$sku->type = $row['type'];
$sku->price = $row['price'];
$sku->save();
}
}