Dashboard sipadu mbip
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

GenerateBarcode.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Jobs;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Queue\SerializesModels;
  5. use Illuminate\Queue\InteractsWithQueue;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Foundation\Bus\Dispatchable;
  8. use File;
  9. use App\Model\Module\Compound;
  10. use App\Model\Module\ConfidentialFile;
  11. use App\Model\Module\ItemInventory;
  12. use App\Model\Module\Barcode;
  13. use App\Model\Module\Attachment;
  14. use App\Model\Module\History;
  15. use App\Model\Module\SubHistory;
  16. class GenerateBarcode implements ShouldQueue
  17. {
  18. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  19. protected $kpd, $name, $item;
  20. /**
  21. * Create a new job instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct($kpd, $name, ItemInventory $item)
  26. {
  27. $this->kpd = $kpd;
  28. $this->name = $name;
  29. $this->item = $item;
  30. }
  31. /**
  32. * Execute the job.
  33. *
  34. * @return void
  35. */
  36. public function handle()
  37. {
  38. $compound = Compound::with('ConfidentialFile')->where('kpd', $this->kpd)->first();
  39. $client = new \GuzzleHttp\Client();
  40. $result = $client->request('POST', 'http://filegoforce.sipadu.my/api/generate/barcode', [
  41. 'verify' => false,
  42. 'form_params' => [
  43. 'barcode' => $this->name,
  44. 'no_siri' => $compound->ConfidentialFile->no_siri,
  45. 'type' => 'proxy',
  46. ]
  47. ]);
  48. $response = json_decode($result->getBody()->getContents());
  49. if($response->success == true){
  50. $barcode = new Barcode();
  51. $barcode->barcode_id = $this->name;
  52. $barcode->path = $response->data;
  53. $barcode->status = 'simpan';
  54. $this->item->barcode()->save($barcode);
  55. }
  56. }
  57. }