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\HasMany;
|
|
use CloudCreativity\LaravelJsonApi\Eloquent\MorphHasMany;
|
|
use CloudCreativity\LaravelJsonApi\Pagination\StandardStrategy;
|
|
use Illuminate\Support\Collection;
|
|
|
|
class RecipeAdapter extends AbstractAdapter
|
|
{
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected $attributes = [];
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected $filterScopes = [];
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected $defaultSort = ['name'];
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function __construct(StandardStrategy $paging)
|
|
{
|
|
parent::__construct(new \App\Models\Recipe(), $paging);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function filter($query, Collection $filters)
|
|
{
|
|
$this->filterWithScopes($query, $filters);
|
|
}
|
|
|
|
/**
|
|
* Ingredient amount relationships.
|
|
*/
|
|
protected function ingredientAmounts(): MorphHasMany
|
|
{
|
|
return $this->morphMany($this->hasMany('ingredientAmounts'));
|
|
}
|
|
|
|
/**
|
|
* Step relationships.
|
|
*/
|
|
protected function steps(): HasMany
|
|
{
|
|
return $this->hasMany();
|
|
}
|
|
|
|
}
|