mirror of https://github.com/kcal-app/kcal.git
				
				
				
			
		
			
				
	
	
		
			62 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| 
 | |
| namespace App\JsonApi\Adapters;
 | |
| 
 | |
| use CloudCreativity\LaravelJsonApi\Eloquent\AbstractAdapter;
 | |
| use CloudCreativity\LaravelJsonApi\Eloquent\BelongsTo;
 | |
| use CloudCreativity\LaravelJsonApi\Pagination\StandardStrategy;
 | |
| use Illuminate\Support\Collection;
 | |
| use Spatie\MediaLibrary\MediaCollections\Models\Media;
 | |
| 
 | |
| /**
 | |
|  * Media adapter.
 | |
|  *
 | |
|  * "Medium" is the singular form of "media" so it is used for the class name
 | |
|  * here.
 | |
|  *
 | |
|  * @package App\JsonApi\Adapters
 | |
|  */
 | |
| class MediumAdapter extends AbstractAdapter
 | |
| {
 | |
| 
 | |
|     /**
 | |
|      * {@inheritdoc}
 | |
|      */
 | |
|     protected $attributes = [];
 | |
| 
 | |
|     /**
 | |
|      * {@inheritdoc}
 | |
|      */
 | |
|     protected $filterScopes = [];
 | |
| 
 | |
|     /**
 | |
|      * {@inheritdoc}
 | |
|      */
 | |
|     protected $defaultSort = [];
 | |
| 
 | |
|     /**
 | |
|      * {@inheritdoc}
 | |
|      */
 | |
|     public function __construct(StandardStrategy $paging)
 | |
|     {
 | |
|         parent::__construct(new Media(), $paging);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * {@inheritdoc}
 | |
|      */
 | |
|     protected function filter($query, Collection $filters)
 | |
|     {
 | |
|         $this->filterWithScopes($query, $filters);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Parent model (Recipe or Food).
 | |
|      */
 | |
|     protected function owner(): BelongsTo
 | |
|     {
 | |
|         return $this->belongsTo('model');
 | |
|     }
 | |
| 
 | |
| }
 |