mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-10-20 17:49:20 +02:00
* refactor(api): prefer including pivot types to conditional pivot information * style: fix StyleCI findings
42 lines
991 B
PHP
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');
|
|
}
|
|
}
|