kcal/app/JsonApi/Adapters/IngredientAmountAdapter.php

58 lines
1.1 KiB
PHP

<?php
namespace App\JsonApi\Adapters;
use App\Models\IngredientAmount;
use CloudCreativity\LaravelJsonApi\Eloquent\BelongsTo;
use CloudCreativity\LaravelJsonApi\Pagination\StandardStrategy;
use Illuminate\Support\Collection;
class IngredientAmountAdapter extends AdapterBase
{
/**
* {@inheritdoc}
*/
protected $attributes = [];
/**
* {@inheritdoc}
*/
protected $filterScopes = [];
/**
* {@inheritdoc}
*/
protected $defaultSort = ['weight'];
/**
* {@inheritdoc}
*/
public function __construct(StandardStrategy $paging)
{
parent::__construct(new IngredientAmount(), $paging);
}
/**
* {@inheritdoc}
*/
protected function filter($query, Collection $filters)
{
$this->filterWithScopes($query, $filters);
}
protected function ingredient(): BelongsTo
{
return $this->belongsTo();
}
/**
* Parent (Recipe or JournalEntry).
*/
protected function parent(): BelongsTo
{
return $this->belongsTo();
}
}