Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CompoundResource.php 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Http\Resources;
  3. use Illuminate\Http\Resources\Json\JsonResource;
  4. class CompoundResource extends JsonResource
  5. {
  6. /**
  7. * Transform the resource into an array.
  8. *
  9. * @param \Illuminate\Http\Request $request
  10. * @return array
  11. */
  12. public function toArray($request)
  13. {
  14. if($this->modul == '02' && (!empty($this->non)))
  15. {
  16. if($this->faultyNotis != null && $this->staffdetailNotis != null)
  17. {
  18. return [
  19. '_id' => $this->_id,
  20. 'modul' => $this->modul,
  21. 'jenis' => $this->jenis_n,
  22. 'kpd' => $this->non,
  23. 'no_plate' => '',
  24. 'nric' => $this->identity,
  25. 'no_daftar_syarikat' => $this->no_daftar_syarikat,
  26. 'nama_syarikat' => $this->nama_syarikat,
  27. 'nama' => $this->nama,
  28. 'lesen' => $this->no_akaun_lesen,
  29. 'tarikh_masa' => date('d/m/Y H:i:s A', strtotime($this->created_n)),
  30. 'faulty_skter' => $this->faultyNotis->sketr,
  31. 'faulty_name' => $this->faultyNotis->nama,
  32. 'enforcer' => $this->staffdetailNotis->no_badan.', '.$this->staffdetailNotis->full_name,
  33. 'status' => $this->status,
  34. 'kadar_kompaun' => '',
  35. 'catatan_dari_admin' => $this->catatan_dari_admin,
  36. 'updated_by' => $this->updateby,
  37. 'updates_by' => $this->update_by,
  38. 'tarikh_bayar' => '',
  39. 'amount_payment' => '',
  40. 'created_at' => $this->created_at->format('Y-m-d H:i:s'),
  41. 'updated_at' => $this->updated_at->format('Y-m-d H:i'),
  42. ];
  43. }
  44. }
  45. else{
  46. if($this->faulty != null && $this->staffdetail != null)
  47. {
  48. return [
  49. '_id' => $this->_id,
  50. 'modul' => $this->modul,
  51. 'jenis' => $this->jenis,
  52. 'kpd' => $this->kpd,
  53. 'no_plate' => $this->no_plate,
  54. 'nric' => $this->identity,
  55. 'no_daftar_syarikat' => $this->no_daftar_syarikat,
  56. 'nama_syarikat' => $this->nama_syarikat,
  57. 'nama' => $this->nama,
  58. 'lesen' => $this->no_akaun_lesen,
  59. 'tarikh_masa' => $this->created_at->format('d/m/Y H:i:s A'),
  60. 'faulty_skter' => $this->faulty->sketr,
  61. 'faulty_name' => $this->faulty->nama,
  62. 'enforcer' => $this->staffdetail->no_badan.', '.$this->staffdetail->full_name,
  63. 'status' => $this->status,
  64. 'kadar_kompaun' => $this->jumlah_asal_kompaun,
  65. 'catatan_dari_admin' => $this->catatan_dari_admin,
  66. 'updated_by' => $this->updateby,
  67. 'updates_by' => $this->update_by,
  68. 'tarikh_bayar' => $this->tarikh_bayar,
  69. 'amount_payment' => $this->amount_payment,
  70. 'created_at' => $this->created_at->format('Y-m-d H:i:s'),
  71. 'updated_at' => $this->updated_at->format('Y-m-d H:i'),
  72. ];
  73. }
  74. }
  75. }
  76. }