You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an excel file containing 8K products I'm using packagelaravel-excel when I upload the file just 1K of products being uploaded and then I got this error in the jobs_faild table:
Error: The script tried to call a method on an incomplete object.
Please ensure that the class definition "App\Imports\ImportProducts"
of the object you are trying to operate on was loaded _before_ unserialize()
gets called or provide an autoloader to load the class definition in /var/app/current/vendor/maatwebsite/excel/src/Jobs/ReadChunk.php:107
Stack trace:
#0 /var/app/current/vendor/maatwebsite/excel/src/Jobs/ReadChunk.php(107): method_exists(Object(__PHP_Incomplete_Class), 'middleware')
#1 /var/app/current/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(117): Maatwebsite\Excel\Jobs\ReadChunk->middleware()
My controller to upload the file:
public function updateOrCreateProduct(Request $request)
{
$request->validate([
'file' => 'required|file|mimes:xlsx,csv'
]);
(new ImportProducts)->queue($request->file);
return $this->apiRespone(success: "product updated");
}
ImportProducts file contains:
class ImportProducts implements
ToCollection,
WithChunkReading,
ShouldQueue,
WithEvents,
SkipsEmptyRows,
WithHeadingRow
{
use Importable, RegistersEventListeners;
public function collection(Collection $rows)
{
foreach ($rows as $row) {
// my logic to store data to products table
}
}
public function chunkSize(): int
{
return 100;
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have an excel file containing 8K products I'm using package
laravel-excel
when I upload the file just 1K of products being uploaded and then I got this error in thejobs_faild
table:My controller to upload the file:
ImportProducts file contains:
Beta Was this translation helpful? Give feedback.
All reactions