'laravel - check and update queued job status to db

Currently I am setting up a queue to insert data from CSV files to the DB using file upload. The queue and data extraction is working currently, but I am looking for a way to check whether the job has been completed, failed or still in process. Is it possible to achieve this and update the status of uploaded file in other DB table as well?

Jobs

Redis::throttle('upload-csv')->allow(1)->every(20)->then(function () {
            dump('Processing this file:---',$this->file);
            $data = array_map('str_getcsv',file($this->file));

            foreach($data as $row){
                CSVDataList::updateOrCreate([
                    'KEY_1' => $row[0],
                ],[
                    'KEY_2' => $row[1],
                    'KEY_3' => $row[2],
                    'KEY_4' => $row[3],
                ]);
            }
            dump('Done for this file:---',$this->file);
            unlink($this->file);
        }, function () {

            return $this->release(10);
        });

Controller

$request->validate([
            'file' => 'required|mimes:csv,txt'
        ]);

        $filename = $file->getClientOriginalName();
        $file = file($request->file->getRealPath());
        $data = array_slice($file,1);
        $parts = (array_chunk($data,5000));

        foreach($parts as $index=>$part){
            $fileName = resource_path('pending-files/'.date('y-m-d-H-i-s').$index.'.csv');
            file_put_contents($fileName,$part);
        }

        (new CSVDataList())->importToDb($filename);

        session()->flash('status','Queued for importing..');

        return redirect('file-upload');

Function in Model

public function importToDb($filename)
    {
        $path = resource_path('pending-files/*.csv');

        $files = glob($path);

        foreach($files as $file){

            ProcessCsvUpload::dispatch($filename,$file);
        }

    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source