Files
animethemes-server/app/Http/Api/Field/Wiki/Image/ImagePathField.php
T
paranarimasu 295a997354 Api allowed pivots (#570)
* refactor(api): prefer including pivot types to conditional pivot information

* style: fix StyleCI findings
2023-04-14 18:36:29 -05:00

42 lines
991 B
PHP

<?php
declare(strict_types=1);
namespace App\Http\Api\Field\Wiki\Image;
use App\Http\Api\Field\StringField;
use App\Http\Api\Query\Query;
use App\Http\Api\Schema\Schema;
use App\Models\Wiki\Image;
/**
* Class ImagePathField.
*/
class ImagePathField extends StringField
{
/**
* Create a new field instance.
*
* @param Schema $schema
*/
public function __construct(Schema $schema)
{
parent::__construct($schema, Image::ATTRIBUTE_PATH);
}
/**
* Determine if the field should be included in the select clause of our query.
*
* @param Query $query
* @param Schema $schema
* @return bool
*/
public function shouldSelect(Query $query, Schema $schema): bool
{
$criteria = $query->getFieldCriteria($this->schema->type());
// The link field is dependent on this field to build the url.
return parent::shouldSelect($query, $schema) || $criteria->isAllowedField('link');
}
}