PHP code example of feldoe / laravel-export-progress

1. Go to this page and download the library: Download feldoe/laravel-export-progress library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

feldoe / laravel-export-progress example snippets


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();
    }
}