12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
-
- namespace App\Http\Resources;
-
- use Illuminate\Http\Resources\Json\JsonResource;
-
- class CompoundResource extends JsonResource
- {
- /**
- * Transform the resource into an array.
- *
- * @param \Illuminate\Http\Request $request
- * @return array
- */
- public function toArray($request)
- {
- if($this->modul == '02' && (!empty($this->non)))
- {
- if($this->faultyNotis != null && $this->staffdetailNotis != null)
- {
- return [
- '_id' => $this->_id,
- 'modul' => $this->modul,
- 'jenis' => $this->jenis_n,
- 'kpd' => $this->non,
- 'no_plate' => '',
- 'nric' => $this->identity,
- 'no_daftar_syarikat' => $this->no_daftar_syarikat,
- 'nama_syarikat' => $this->nama_syarikat,
- 'nama' => $this->nama,
- 'lesen' => $this->no_akaun_lesen,
- 'tarikh_masa' => date('d/m/Y H:i:s A', strtotime($this->created_n)),
- 'faulty_skter' => $this->faultyNotis->sketr,
- 'faulty_name' => $this->faultyNotis->nama,
- 'enforcer' => $this->staffdetailNotis->no_badan.', '.$this->staffdetailNotis->full_name,
- 'status' => $this->status,
- 'kadar_kompaun' => '',
- 'catatan_dari_admin' => $this->catatan_dari_admin,
- 'updated_by' => $this->updateby,
- 'updates_by' => $this->update_by,
- 'tarikh_bayar' => '',
- 'amount_payment' => '',
- 'created_at' => $this->created_at->format('Y-m-d H:i:s'),
- 'updated_at' => $this->updated_at->format('Y-m-d H:i'),
- ];
- }
-
- }
- else{
- if($this->faulty != null && $this->staffdetail != null)
- {
- return [
- '_id' => $this->_id,
- 'modul' => $this->modul,
- 'jenis' => $this->jenis,
- 'kpd' => $this->kpd,
- 'no_plate' => $this->no_plate,
- 'nric' => $this->identity,
- 'no_daftar_syarikat' => $this->no_daftar_syarikat,
- 'nama_syarikat' => $this->nama_syarikat,
- 'nama' => $this->nama,
- 'lesen' => $this->no_akaun_lesen,
- 'tarikh_masa' => $this->created_at->format('d/m/Y H:i:s A'),
- 'faulty_skter' => $this->faulty->sketr,
- 'faulty_name' => $this->faulty->nama,
- 'enforcer' => $this->staffdetail->no_badan.', '.$this->staffdetail->full_name,
- 'status' => $this->status,
- 'kadar_kompaun' => $this->jumlah_asal_kompaun,
- 'catatan_dari_admin' => $this->catatan_dari_admin,
- 'updated_by' => $this->updateby,
- 'updates_by' => $this->update_by,
- 'tarikh_bayar' => $this->tarikh_bayar,
- 'amount_payment' => $this->amount_payment,
- 'created_at' => $this->created_at->format('Y-m-d H:i:s'),
- 'updated_at' => $this->updated_at->format('Y-m-d H:i'),
- ];
- }
-
- }
-
- }
- }
|