Add progress broadcast events to your exports
feldoe/laravel-export-progress is a Laravel package for add progress broadcast events to your exports.
It currently has 0 GitHub stars and 712 downloads on Packagist (latest version v1.2.0).
Install it with composer require feldoe/laravel-export-progress.
Discover more Laravel packages by feldoe
or browse all Laravel packages to compare alternatives.
Last updated
Example
final class UsersExport extends AbstractExport implements FromQuery
{
/**
* @param User $user
*/
public function map($user): array
{
try {
$this->sendProgressEventIfNeeded();
} catch (Exception $exception) {
Log::error(__('Failed to send progress event => :message', ['message' => $exception->getMessage()]));
}
return [
$user->id,
$user->username,
$user->email,
];
}
public function query(): Builder
{
return User::query();
}
}
const startExport = (data) => {
exportSystem.start(data.uuid, data.name)
}
Echo.private(`exports.${this.user.id}`)
.listen('.export.progressed', e => {
exportSystem.progress(
e.uuid,
e.type,
e.model?.name,
e.progress,
e.estimated_duration
)
})
.listen('.export.completed', e => {
exportStore.finish(payload.uuid)
notify({
title: tr(`success.${payload.type}`),
type: 'valid'
})
window.open(payload.url)
})
.listen('.export.failed', e => {
exportSystem.fail(
e.uuid,
e.reason.message
)
})
Laravel export progress is open-sourced software licensed under the MIT license.