mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 05:31:10 -04:00 
			
		
		
		
	v6 update
This commit is contained in:
		
							
								
								
									
										32
									
								
								app/Http/Resources/Customer/TransactionResource.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								app/Http/Resources/Customer/TransactionResource.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Crater\Http\Resources\Customer; | ||||
|  | ||||
| use Illuminate\Http\Resources\Json\JsonResource; | ||||
|  | ||||
| class TransactionResource extends JsonResource | ||||
| { | ||||
|     /** | ||||
|      * Transform the resource into an array. | ||||
|      * | ||||
|      * @param  \Illuminate\Http\Request  $request | ||||
|      * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable | ||||
|      */ | ||||
|     public function toArray($request) | ||||
|     { | ||||
|         return [ | ||||
|             'id' => $this->id, | ||||
|             'transaction_id' => $this->transaction_id, | ||||
|             'type' => $this->type, | ||||
|             'status' => $this->status, | ||||
|             'transaction_date' => $this->transaction_date, | ||||
|             'invoice_id' => $this->invoice_id, | ||||
|             'invoice' => $this->when($this->invoice()->exists(), function () { | ||||
|                 return new InvoiceResource($this->invoice); | ||||
|             }), | ||||
|             'company' => $this->when($this->company()->exists(), function () { | ||||
|                 return new CompanyResource($this->company); | ||||
|             }), | ||||
|         ]; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user