first commit
This commit is contained in:
31
app/Jobs/ProcessDocumentOCR.php
Normal file
31
app/Jobs/ProcessDocumentOCR.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
|
||||
class ProcessDocumentOCR implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(public DocumentVersion $version)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$ocr = new TesseractOCR();
|
||||
$text = $ocr->file(storage_path("app/{$this->version->file_path}"))->run();
|
||||
|
||||
$this->version->update(['ocr_text' => $text]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user