mirror of https://github.com/kcal-app/kcal.git
61 lines
1.1 KiB
PHP
61 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\JsonApi\Adapters;
|
|
|
|
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 AdapterBase
|
|
{
|
|
|
|
/**
|
|
* {@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');
|
|
}
|
|
|
|
}
|