feldoe / laravel-export-progress
Add progress broadcast events to your exports
Installs: 611
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/feldoe/laravel-export-progress
Requires
- php: ^8.2
- laravel/framework: ^10.0|^11.0|^12.0
- maatwebsite/excel: ^3.1
Requires (Dev)
- nunomaduro/larastan: ^2.8
- orchestra/testbench: ^8.0
- phpstan/extension-installer: ^1.2.0
README
About Laravel export progress
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
)
})
License
Laravel export progress is open-sourced software licensed under the MIT license.