1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
-
- namespace App\Jobs;
-
- use Illuminate\Bus\Queueable;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
-
- use File;
-
- use App\Model\Module\Compound;
- use App\Model\Module\ConfidentialFile;
- use App\Model\Module\ItemInventory;
- use App\Model\Module\Barcode;
- use App\Model\Module\Attachment;
- use App\Model\Module\History;
- use App\Model\Module\SubHistory;
-
- class GenerateBarcode implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- protected $kpd, $name, $item;
-
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct($kpd, $name, ItemInventory $item)
- {
- $this->kpd = $kpd;
- $this->name = $name;
- $this->item = $item;
- }
-
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- $compound = Compound::with('ConfidentialFile')->where('kpd', $this->kpd)->first();
- $client = new \GuzzleHttp\Client();
- $result = $client->request('POST', 'http://filegoforce.sipadu.my/api/generate/barcode', [
- 'verify' => false,
- 'form_params' => [
- 'barcode' => $this->name,
- 'no_siri' => $compound->ConfidentialFile->no_siri,
- 'type' => 'proxy',
- ]
- ]);
-
- $response = json_decode($result->getBody()->getContents());
- if($response->success == true){
- $barcode = new Barcode();
- $barcode->barcode_id = $this->name;
- $barcode->path = $response->data;
- $barcode->status = 'simpan';
- $this->item->barcode()->save($barcode);
- }
- }
- }
|