mirror of https://github.com/kcal-app/kcal.git
				
				
				
			
		
			
				
	
	
		
			59 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| 
 | |
| namespace App\JsonApi\IngredientAmounts;
 | |
| 
 | |
| use CloudCreativity\LaravelJsonApi\Eloquent\AbstractAdapter;
 | |
| use CloudCreativity\LaravelJsonApi\Eloquent\BelongsTo;
 | |
| use CloudCreativity\LaravelJsonApi\Pagination\StandardStrategy;
 | |
| use Illuminate\Database\Eloquent\Builder;
 | |
| use Illuminate\Support\Collection;
 | |
| 
 | |
| class Adapter extends AbstractAdapter
 | |
| {
 | |
| 
 | |
|     /**
 | |
|      * Mapping of JSON API attribute field names to model keys.
 | |
|      *
 | |
|      * @var array
 | |
|      */
 | |
|     protected $attributes = [];
 | |
| 
 | |
|     /**
 | |
|      * Mapping of JSON API filter names to model scopes.
 | |
|      *
 | |
|      * @var array
 | |
|      */
 | |
|     protected $filterScopes = [];
 | |
| 
 | |
|     /**
 | |
|      * Adapter constructor.
 | |
|      *
 | |
|      * @param StandardStrategy $paging
 | |
|      */
 | |
|     public function __construct(StandardStrategy $paging)
 | |
|     {
 | |
|         parent::__construct(new \App\Models\IngredientAmount(), $paging);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @param Builder $query
 | |
|      * @param Collection $filters
 | |
|      * @return void
 | |
|      */
 | |
|     protected function filter($query, Collection $filters)
 | |
|     {
 | |
|         $this->filterWithScopes($query, $filters);
 | |
|     }
 | |
| 
 | |
|     protected function ingredient(): BelongsTo
 | |
|     {
 | |
|         return $this->belongsTo();
 | |
|     }
 | |
| 
 | |
|     protected function recipe(): BelongsTo
 | |
|     {
 | |
|         return $this->belongsTo();
 | |
|     }
 | |
| 
 | |
| }
 |