mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-28 12:11:08 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			620 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			620 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Crater\Http\Resources;
 | |
| 
 | |
| use Illuminate\Http\Resources\Json\JsonResource;
 | |
| 
 | |
| class UnitResource extends JsonResource
 | |
| {
 | |
|     /**
 | |
|      * Transform the resource into an array.
 | |
|      *
 | |
|      * @param  \Illuminate\Http\Request  $request
 | |
|      * @return array
 | |
|      */
 | |
|     public function toArray($request)
 | |
|     {
 | |
|         return [
 | |
|             'id' => $this->id,
 | |
|             'name' => $this->name,
 | |
|             'company_id' => $this->company_id,
 | |
|             'company' => $this->when($this->company()->exists(), function () {
 | |
|                 return new CompanyResource($this->company);
 | |
|             }),
 | |
|         ];
 | |
|     }
 | |
| }
 |