mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
refactor(api): provide query to field to determine selection and aggregation (#512)
* refactor(api): provide query to field to determine selection and aggregation * style: fix StyleCI findings
This commit is contained in:
@@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Contracts\Http\Api\Field;
|
||||
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
|
||||
/**
|
||||
* Interface SelectableField.
|
||||
@@ -14,8 +14,8 @@ interface SelectableField
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool;
|
||||
public function shouldSelect(ReadQuery $query): bool;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Admin\Announcement;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Admin\Announcement;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class AnnouncementContentField extends StringField implements CreatableField, Up
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Announcement::ATTRIBUTE_CONTENT);
|
||||
parent::__construct($schema, Announcement::ATTRIBUTE_CONTENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Admin\Dump;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Admin\Resource\DumpResource;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class DumpLinkField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(DumpResource::ATTRIBUTE_LINK);
|
||||
parent::__construct($schema, DumpResource::ATTRIBUTE_LINK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Admin\Dump;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Admin\Dump;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class DumpPathField extends StringField implements CreatableField, UpdatableFiel
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Dump::ATTRIBUTE_PATH);
|
||||
parent::__construct($schema, Dump::ATTRIBUTE_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,9 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Api\Field;
|
||||
|
||||
use App\Contracts\Http\Api\Field\FilterableField;
|
||||
use App\Contracts\Http\Api\Field\SortableField;
|
||||
use App\Enums\Http\Api\QualifyColumn;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Api\Scope\ScopeParser;
|
||||
use App\Http\Api\Sort\Sort;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -14,16 +17,17 @@ use Illuminate\Database\Eloquent\Model;
|
||||
/**
|
||||
* Class AggregateField.
|
||||
*/
|
||||
abstract class AggregateField extends Field implements SortableField
|
||||
abstract class AggregateField extends Field implements FilterableField, SortableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
* @param string $key
|
||||
*/
|
||||
public function __construct(string $key)
|
||||
public function __construct(Schema $schema, string $key)
|
||||
{
|
||||
parent::__construct($key);
|
||||
parent::__construct($schema, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,12 +43,36 @@ abstract class AggregateField extends Field implements SortableField
|
||||
/**
|
||||
* Determine if the aggregate value should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldAggregate(?Criteria $criteria): bool
|
||||
public function shouldAggregate(ReadQuery $query): bool
|
||||
{
|
||||
return $criteria !== null && $criteria->isAllowedField($this->getKey());
|
||||
// Select aggregate if explicitly included in sparse fieldsets
|
||||
$fieldCriteria = $query->getFieldCriteria($this->schema->type());
|
||||
if ($fieldCriteria !== null && $fieldCriteria->isAllowedField($this->getKey())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$scope = ScopeParser::parse($this->schema->type());
|
||||
|
||||
// Select aggregate if filtering on the aggregate value
|
||||
$filter = $this->getFilter();
|
||||
foreach ($query->getFilterCriteria() as $criteria) {
|
||||
if ($criteria->shouldFilter($filter, $scope)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Select aggregate if sorting on the aggregate value
|
||||
$sort = $this->getSort();
|
||||
foreach ($query->getSortCriteria() as $sortCriterion) {
|
||||
if ($sortCriterion->shouldSort($sort, $scope)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Auth\User;
|
||||
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Auth\User;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class UserNameField extends StringField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(User::ATTRIBUTE_NAME);
|
||||
parent::__construct($schema, User::ATTRIBUTE_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Base;
|
||||
|
||||
use App\Http\Api\Field\DateField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class CreatedAtField extends DateField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(BaseModel::ATTRIBUTE_CREATED_AT);
|
||||
parent::__construct($schema, BaseModel::ATTRIBUTE_CREATED_AT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Base;
|
||||
|
||||
use App\Http\Api\Field\DateField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class DeletedAtField extends DateField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(BaseModel::ATTRIBUTE_DELETED_AT);
|
||||
parent::__construct($schema, BaseModel::ATTRIBUTE_DELETED_AT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Api\Field\Base;
|
||||
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\IntField;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\BaseResource;
|
||||
|
||||
/**
|
||||
@@ -16,23 +17,24 @@ class IdField extends IntField
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
* @param string $column
|
||||
*/
|
||||
public function __construct(string $column)
|
||||
public function __construct(Schema $schema, string $column)
|
||||
{
|
||||
parent::__construct(BaseResource::ATTRIBUTE_ID, $column);
|
||||
parent::__construct($schema, BaseResource::ATTRIBUTE_ID, $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*
|
||||
* @noinspection PhpMissingParentCallCommonInspection
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
|
||||
// TODO: if field criteria or allowed includes is not empty
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Base;
|
||||
|
||||
use App\Http\Api\Field\DateField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class UpdatedAtField extends DateField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(BaseModel::ATTRIBUTE_UPDATED_AT);
|
||||
parent::__construct($schema, BaseModel::ATTRIBUTE_UPDATED_AT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Http\Api\Filter\AllowedDateFormat;
|
||||
use App\Http\Api\Field\DateField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Billing\Balance;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -19,10 +20,12 @@ class BalanceDateField extends DateField implements CreatableField, UpdatableFie
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Balance::ATTRIBUTE_DATE);
|
||||
parent::__construct($schema, Balance::ATTRIBUTE_DATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Models\Billing\BalanceFrequency;
|
||||
use App\Http\Api\Field\EnumField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Billing\Balance;
|
||||
use BenSampo\Enum\Rules\EnumValue;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,10 +20,12 @@ class BalanceFrequencyField extends EnumField implements CreatableField, Updatab
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Balance::ATTRIBUTE_FREQUENCY, BalanceFrequency::class);
|
||||
parent::__construct($schema, Balance::ATTRIBUTE_FREQUENCY, BalanceFrequency::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Billing\Balance;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\FloatField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Billing\Resource\BalanceResource;
|
||||
use App\Models\Billing\Balance;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,10 +19,12 @@ class BalanceMonthToDateField extends FloatField implements CreatableField, Upda
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(BalanceResource::ATTRIBUTE_BALANCE, Balance::ATTRIBUTE_BALANCE);
|
||||
parent::__construct($schema, BalanceResource::ATTRIBUTE_BALANCE, Balance::ATTRIBUTE_BALANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Models\Billing\Service;
|
||||
use App\Http\Api\Field\EnumField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Billing\Balance;
|
||||
use BenSampo\Enum\Rules\EnumValue;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,10 +20,12 @@ class BalanceServiceField extends EnumField implements CreatableField, Updatable
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Balance::ATTRIBUTE_SERVICE, Service::class);
|
||||
parent::__construct($schema, Balance::ATTRIBUTE_SERVICE, Service::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Billing\Balance;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\FloatField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Billing\Balance;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class BalanceUsageField extends FloatField implements CreatableField, UpdatableF
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Balance::ATTRIBUTE_USAGE);
|
||||
parent::__construct($schema, Balance::ATTRIBUTE_USAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Billing\Transaction;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\FloatField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Billing\Transaction;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class TransactionAmountField extends FloatField implements CreatableField, Updat
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Transaction::ATTRIBUTE_AMOUNT);
|
||||
parent::__construct($schema, Transaction::ATTRIBUTE_AMOUNT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Http\Api\Filter\AllowedDateFormat;
|
||||
use App\Http\Api\Field\DateField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Billing\Transaction;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -19,10 +20,12 @@ class TransactionDateField extends DateField implements CreatableField, Updatabl
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Transaction::ATTRIBUTE_DATE);
|
||||
parent::__construct($schema, Transaction::ATTRIBUTE_DATE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Billing\Transaction;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Billing\Transaction;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class TransactionDescriptionField extends StringField implements CreatableField,
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Transaction::ATTRIBUTE_DESCRIPTION);
|
||||
parent::__construct($schema, Transaction::ATTRIBUTE_DESCRIPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Billing\Transaction;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Billing\Transaction;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class TransactionExternalIdField extends StringField implements CreatableField,
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Transaction::ATTRIBUTE_EXTERNAL_ID);
|
||||
parent::__construct($schema, Transaction::ATTRIBUTE_EXTERNAL_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Models\Billing\Service;
|
||||
use App\Http\Api\Field\EnumField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Billing\Transaction;
|
||||
use BenSampo\Enum\Rules\EnumValue;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,10 +20,12 @@ class TransactionServiceField extends EnumField implements CreatableField, Updat
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Transaction::ATTRIBUTE_SERVICE, Service::class);
|
||||
parent::__construct($schema, Transaction::ATTRIBUTE_SERVICE, Service::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace App\Http\Api\Field;
|
||||
use App\Contracts\Http\Api\Field\FilterableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\SortableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Filter\BooleanFilter;
|
||||
use App\Http\Api\Filter\Filter;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Sort\Sort;
|
||||
|
||||
/**
|
||||
@@ -30,11 +30,13 @@ abstract class BooleanField extends Field implements FilterableField, Selectable
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
$criteria = $query->getFieldCriteria($this->schema->type());
|
||||
|
||||
return $criteria === null || $criteria->isAllowedField($this->getKey());
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Config\Flags;
|
||||
|
||||
use App\Constants\Config\FlagConstants;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Class FlagsAllowAudioStreamsField.
|
||||
@@ -14,9 +15,11 @@ class FlagsAllowAudioStreamsField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(FlagConstants::ALLOW_AUDIO_STREAMS_FLAG);
|
||||
parent::__construct($schema, FlagConstants::ALLOW_AUDIO_STREAMS_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Config\Flags;
|
||||
|
||||
use App\Constants\Config\FlagConstants;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Class FlagsAllowDiscordNotifications.
|
||||
@@ -14,9 +15,11 @@ class FlagsAllowDiscordNotificationsField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(FlagConstants::ALLOW_DISCORD_NOTIFICATIONS_FLAG);
|
||||
parent::__construct($schema, FlagConstants::ALLOW_DISCORD_NOTIFICATIONS_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Config\Flags;
|
||||
|
||||
use App\Constants\Config\FlagConstants;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Class FlagsAllowDumpDownloadingField.
|
||||
@@ -14,9 +15,11 @@ class FlagsAllowDumpDownloadingField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(FlagConstants::ALLOW_DUMP_DOWNLOADING_FLAG);
|
||||
parent::__construct($schema, FlagConstants::ALLOW_DUMP_DOWNLOADING_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Config\Flags;
|
||||
|
||||
use App\Constants\Config\FlagConstants;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Class FlagsAllowScriptDownloadingField.
|
||||
@@ -14,9 +15,11 @@ class FlagsAllowScriptDownloadingField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(FlagConstants::ALLOW_SCRIPT_DOWNLOADING_FLAG);
|
||||
parent::__construct($schema, FlagConstants::ALLOW_SCRIPT_DOWNLOADING_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Config\Flags;
|
||||
|
||||
use App\Constants\Config\FlagConstants;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Class FlagsAllowVideoStreamsField.
|
||||
@@ -14,9 +15,11 @@ class FlagsAllowVideoStreamsField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(FlagConstants::ALLOW_VIDEO_STREAMS_FLAG);
|
||||
parent::__construct($schema, FlagConstants::ALLOW_VIDEO_STREAMS_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Config\Flags;
|
||||
|
||||
use App\Constants\Config\FlagConstants;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Class FlagsAllowViewRecordingField.
|
||||
@@ -14,9 +15,11 @@ class FlagsAllowViewRecordingField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(FlagConstants::ALLOW_VIEW_RECORDING_FLAG);
|
||||
parent::__construct($schema, FlagConstants::ALLOW_VIEW_RECORDING_FLAG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Config\Wiki;
|
||||
|
||||
use App\Constants\Config\WikiConstants;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Class WikiFeaturedThemeField.
|
||||
@@ -14,9 +15,11 @@ class WikiFeaturedThemeField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(WikiConstants::FEATURED_THEME_SETTING);
|
||||
parent::__construct($schema, WikiConstants::FEATURED_THEME_SETTING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Api\Field;
|
||||
|
||||
use App\Contracts\Http\Api\Field\FilterableField;
|
||||
use App\Enums\Http\Api\Filter\Clause;
|
||||
use App\Enums\Http\Api\QualifyColumn;
|
||||
use App\Http\Api\Filter\Filter;
|
||||
use App\Http\Api\Filter\IntFilter;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -16,16 +16,17 @@ use Illuminate\Support\Str;
|
||||
/**
|
||||
* Class CountField.
|
||||
*/
|
||||
abstract class CountField extends AggregateField implements FilterableField
|
||||
abstract class CountField extends AggregateField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
* @param string $key
|
||||
*/
|
||||
public function __construct(string $key)
|
||||
public function __construct(Schema $schema, string $key)
|
||||
{
|
||||
parent::__construct($key);
|
||||
parent::__construct($schema, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace App\Http\Api\Field;
|
||||
use App\Contracts\Http\Api\Field\FilterableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\SortableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Filter\DateFilter;
|
||||
use App\Http\Api\Filter\Filter;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Sort\Sort;
|
||||
|
||||
/**
|
||||
@@ -30,11 +30,13 @@ abstract class DateField extends Field implements FilterableField, SelectableFie
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
$criteria = $query->getFieldCriteria($this->schema->type());
|
||||
|
||||
return $criteria === null || $criteria->isAllowedField($this->getKey());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,9 @@ namespace App\Http\Api\Field\Document\Page;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Document\Page;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -19,10 +20,12 @@ class PageBodyField extends Field implements CreatableField, SelectableField, Up
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Page::ATTRIBUTE_BODY);
|
||||
parent::__construct($schema, Page::ATTRIBUTE_BODY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,11 +46,13 @@ class PageBodyField extends Field implements CreatableField, SelectableField, Up
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
$criteria = $query->getFieldCriteria($this->schema->type());
|
||||
|
||||
// TODO: Only return this attribute if specified due to potential size.
|
||||
return $criteria === null || $criteria->isAllowedField($this->getKey());
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Document\Page;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Document\Page;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class PageNameField extends StringField implements CreatableField, UpdatableFiel
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Page::ATTRIBUTE_NAME);
|
||||
parent::__construct($schema, Page::ATTRIBUTE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Document\Page;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Document\Page;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -18,10 +19,12 @@ class PageSlugField extends StringField implements CreatableField, UpdatableFiel
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Page::ATTRIBUTE_SLUG);
|
||||
parent::__construct($schema, Page::ATTRIBUTE_SLUG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,9 +8,10 @@ use App\Contracts\Http\Api\Field\FilterableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\SortableField;
|
||||
use App\Enums\BaseEnum;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Filter\EnumFilter;
|
||||
use App\Http\Api\Filter\Filter;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Api\Sort\Sort;
|
||||
|
||||
/**
|
||||
@@ -21,16 +22,18 @@ abstract class EnumField extends Field implements FilterableField, SelectableFie
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
* @param string $key
|
||||
* @param class-string<BaseEnum> $enumClass
|
||||
* @param string|null $column
|
||||
*/
|
||||
public function __construct(
|
||||
Schema $schema,
|
||||
string $key,
|
||||
protected readonly string $enumClass,
|
||||
?string $column = null
|
||||
) {
|
||||
parent::__construct($key, $column);
|
||||
parent::__construct($schema, $key, $column);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,11 +59,13 @@ abstract class EnumField extends Field implements FilterableField, SelectableFie
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
$criteria = $query->getFieldCriteria($this->schema->type());
|
||||
|
||||
return $criteria === null || $criteria->isAllowedField($this->getKey());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field;
|
||||
|
||||
use App\Contracts\Http\Api\Field\FieldInterface;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Class Field.
|
||||
@@ -14,11 +15,25 @@ abstract class Field implements FieldInterface
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
* @param string $key
|
||||
* @param string|null $column
|
||||
*/
|
||||
public function __construct(protected string $key, protected ?string $column = null)
|
||||
public function __construct(
|
||||
protected readonly Schema $schema,
|
||||
protected readonly string $key,
|
||||
protected readonly ?string $column = null
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the schema.
|
||||
*
|
||||
* @return Schema
|
||||
*/
|
||||
public function schema(): Schema
|
||||
{
|
||||
return $this->schema;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace App\Http\Api\Field;
|
||||
use App\Contracts\Http\Api\Field\FilterableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\SortableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Filter\Filter;
|
||||
use App\Http\Api\Filter\FloatFilter;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Sort\Sort;
|
||||
|
||||
/**
|
||||
@@ -30,11 +30,13 @@ abstract class FloatField extends Field implements FilterableField, SelectableFi
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
$criteria = $query->getFieldCriteria($this->schema->type());
|
||||
|
||||
return $criteria === null || $criteria->isAllowedField($this->getKey());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace App\Http\Api\Field;
|
||||
use App\Contracts\Http\Api\Field\FilterableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\SortableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Filter\Filter;
|
||||
use App\Http\Api\Filter\IntFilter;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Sort\Sort;
|
||||
|
||||
/**
|
||||
@@ -30,11 +30,13 @@ abstract class IntField extends Field implements FilterableField, SelectableFiel
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
$criteria = $query->getFieldCriteria($this->schema->type());
|
||||
|
||||
return $criteria === null || $criteria->isAllowedField($this->getKey());
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,9 @@ namespace App\Http\Api\Field\List\Playlist;
|
||||
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\List\Playlist;
|
||||
use App\Models\List\Playlist\PlaylistTrack;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,19 +21,21 @@ class PlaylistFirstIdField extends Field implements SelectableField, UpdatableFi
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Playlist::ATTRIBUTE_FIRST);
|
||||
parent::__construct($schema, Playlist::ATTRIBUTE_FIRST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match first track relation.
|
||||
return true;
|
||||
|
||||
@@ -6,8 +6,9 @@ namespace App\Http\Api\Field\List\Playlist;
|
||||
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\List\Playlist;
|
||||
use App\Models\List\Playlist\PlaylistTrack;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,19 +21,21 @@ class PlaylistLastIdField extends Field implements SelectableField, UpdatableFie
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Playlist::ATTRIBUTE_LAST);
|
||||
parent::__construct($schema, Playlist::ATTRIBUTE_LAST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match last track relation.
|
||||
return true;
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\List\Playlist;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\List\Playlist;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class PlaylistNameField extends StringField implements CreatableField, Updatable
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Playlist::ATTRIBUTE_NAME);
|
||||
parent::__construct($schema, Playlist::ATTRIBUTE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,8 +5,9 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\List\Playlist;
|
||||
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\List\Playlist;
|
||||
|
||||
/**
|
||||
@@ -16,19 +17,21 @@ class PlaylistUserIdField extends Field implements SelectableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Playlist::ATTRIBUTE_USER);
|
||||
parent::__construct($schema, Playlist::ATTRIBUTE_USER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match user relation.
|
||||
return true;
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\List\Playlist;
|
||||
|
||||
use App\Http\Api\Field\CountField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\List\Playlist;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class PlaylistViewCountField extends CountField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Playlist::RELATION_VIEWS);
|
||||
parent::__construct($schema, Playlist::RELATION_VIEWS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Models\List\PlaylistVisibility;
|
||||
use App\Http\Api\Field\EnumField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\List\Playlist;
|
||||
use BenSampo\Enum\Rules\EnumValue;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,10 +20,12 @@ class PlaylistVisibilityField extends EnumField implements CreatableField, Updat
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Playlist::ATTRIBUTE_VISIBILITY, PlaylistVisibility::class);
|
||||
parent::__construct($schema, Playlist::ATTRIBUTE_VISIBILITY, PlaylistVisibility::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,8 +7,9 @@ namespace App\Http\Api\Field\List\Playlist\Track;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\List\Playlist;
|
||||
use App\Models\List\Playlist\PlaylistTrack;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,10 +22,12 @@ class TrackNextIdField extends Field implements CreatableField, SelectableField,
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(PlaylistTrack::ATTRIBUTE_NEXT);
|
||||
parent::__construct($schema, PlaylistTrack::ATTRIBUTE_NEXT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,10 +53,10 @@ class TrackNextIdField extends Field implements CreatableField, SelectableField,
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match next track relation.
|
||||
return true;
|
||||
|
||||
@@ -5,8 +5,9 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\List\Playlist\Track;
|
||||
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\List\Playlist\PlaylistTrack;
|
||||
|
||||
/**
|
||||
@@ -16,19 +17,21 @@ class TrackPlaylistIdField extends Field implements SelectableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(PlaylistTrack::ATTRIBUTE_PLAYLIST);
|
||||
parent::__construct($schema, PlaylistTrack::ATTRIBUTE_PLAYLIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match playlist relation.
|
||||
return true;
|
||||
|
||||
@@ -7,8 +7,9 @@ namespace App\Http\Api\Field\List\Playlist\Track;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\List\Playlist;
|
||||
use App\Models\List\Playlist\PlaylistTrack;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,10 +22,12 @@ class TrackPreviousIdField extends Field implements CreatableField, SelectableFi
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(PlaylistTrack::ATTRIBUTE_PREVIOUS);
|
||||
parent::__construct($schema, PlaylistTrack::ATTRIBUTE_PREVIOUS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,10 +53,10 @@ class TrackPreviousIdField extends Field implements CreatableField, SelectableFi
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match previous track relation.
|
||||
return true;
|
||||
|
||||
@@ -7,8 +7,9 @@ namespace App\Http\Api\Field\List\Playlist\Track;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\List\Playlist\PlaylistTrack;
|
||||
use App\Models\Wiki\Video;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,10 +22,12 @@ class TrackVideoIdField extends Field implements CreatableField, SelectableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(PlaylistTrack::ATTRIBUTE_VIDEO);
|
||||
parent::__construct($schema, PlaylistTrack::ATTRIBUTE_VIDEO);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,10 +48,10 @@ class TrackVideoIdField extends Field implements CreatableField, SelectableField
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match video relation.
|
||||
return true;
|
||||
|
||||
@@ -6,8 +6,9 @@ namespace App\Http\Api\Field\Pivot\Wiki\AnimeImage;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime;
|
||||
use App\Pivots\Wiki\AnimeImage;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,10 +21,12 @@ class AnimeImageAnimeIdField extends Field implements CreatableField, Selectable
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeImage::ATTRIBUTE_ANIME);
|
||||
parent::__construct($schema, AnimeImage::ATTRIBUTE_ANIME);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,10 +47,10 @@ class AnimeImageAnimeIdField extends Field implements CreatableField, Selectable
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match anime relation.
|
||||
return true;
|
||||
|
||||
@@ -6,8 +6,9 @@ namespace App\Http\Api\Field\Pivot\Wiki\AnimeImage;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Image;
|
||||
use App\Pivots\Wiki\AnimeImage;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,10 +21,12 @@ class AnimeImageImageIdField extends Field implements CreatableField, Selectable
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeImage::ATTRIBUTE_IMAGE);
|
||||
parent::__construct($schema, AnimeImage::ATTRIBUTE_IMAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,10 +47,10 @@ class AnimeImageImageIdField extends Field implements CreatableField, Selectable
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match image relation.
|
||||
return true;
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace App\Http\Api\Field;
|
||||
use App\Contracts\Http\Api\Field\FilterableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\SortableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Filter\Filter;
|
||||
use App\Http\Api\Filter\StringFilter;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Sort\Sort;
|
||||
|
||||
/**
|
||||
@@ -30,11 +30,13 @@ abstract class StringField extends Field implements FilterableField, SelectableF
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
$criteria = $query->getFieldCriteria($this->schema->type());
|
||||
|
||||
return $criteria === null || $criteria->isAllowedField($this->getKey());
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Anime;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Pivots\Wiki\AnimeResource;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class AnimeAsField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeResource::ATTRIBUTE_AS);
|
||||
parent::__construct($schema, AnimeResource::ATTRIBUTE_AS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class AnimeNameField extends StringField implements CreatableField, UpdatableFie
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Anime::ATTRIBUTE_NAME);
|
||||
parent::__construct($schema, Anime::ATTRIBUTE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Models\Wiki\AnimeSeason;
|
||||
use App\Http\Api\Field\EnumField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime;
|
||||
use BenSampo\Enum\Rules\EnumValue;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,10 +20,12 @@ class AnimeSeasonField extends EnumField implements CreatableField, UpdatableFie
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Anime::ATTRIBUTE_SEASON, AnimeSeason::class);
|
||||
parent::__construct($schema, Anime::ATTRIBUTE_SEASON, AnimeSeason::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -18,10 +19,12 @@ class AnimeSlugField extends StringField implements CreatableField, UpdatableFie
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Anime::ATTRIBUTE_SLUG);
|
||||
parent::__construct($schema, Anime::ATTRIBUTE_SLUG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class AnimeSynopsisField extends StringField implements CreatableField, Updatabl
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Anime::ATTRIBUTE_SYNOPSIS);
|
||||
parent::__construct($schema, Anime::ATTRIBUTE_SYNOPSIS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\IntField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class AnimeYearField extends IntField implements CreatableField, UpdatableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Anime::ATTRIBUTE_YEAR);
|
||||
parent::__construct($schema, Anime::ATTRIBUTE_YEAR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,8 +6,9 @@ namespace App\Http\Api\Field\Wiki\Anime\Synonym;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime;
|
||||
use App\Models\Wiki\Anime\AnimeSynonym;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,10 +21,12 @@ class SynonymAnimeIdField extends Field implements CreatableField, SelectableFie
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeSynonym::ATTRIBUTE_ANIME);
|
||||
parent::__construct($schema, AnimeSynonym::ATTRIBUTE_ANIME);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,10 +47,10 @@ class SynonymAnimeIdField extends Field implements CreatableField, SelectableFie
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match anime relation.
|
||||
return true;
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime\Synonym;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\AnimeSynonym;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class SynonymTextField extends StringField implements CreatableField, UpdatableF
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeSynonym::ATTRIBUTE_TEXT);
|
||||
parent::__construct($schema, AnimeSynonym::ATTRIBUTE_TEXT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime\Theme\Entry;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class EntryEpisodesField extends StringField implements CreatableField, Updatabl
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeThemeEntry::ATTRIBUTE_EPISODES);
|
||||
parent::__construct($schema, AnimeThemeEntry::ATTRIBUTE_EPISODES);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime\Theme\Entry;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class EntryNotesField extends StringField implements CreatableField, UpdatableFi
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeThemeEntry::ATTRIBUTE_NOTES);
|
||||
parent::__construct($schema, AnimeThemeEntry::ATTRIBUTE_NOTES);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime\Theme\Entry;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\BooleanField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class EntryNsfwField extends BooleanField implements CreatableField, UpdatableFi
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeThemeEntry::ATTRIBUTE_NSFW);
|
||||
parent::__construct($schema, AnimeThemeEntry::ATTRIBUTE_NSFW);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime\Theme\Entry;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\BooleanField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class EntrySpoilerField extends BooleanField implements CreatableField, Updatabl
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeThemeEntry::ATTRIBUTE_SPOILER);
|
||||
parent::__construct($schema, AnimeThemeEntry::ATTRIBUTE_SPOILER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,8 +6,9 @@ namespace App\Http\Api\Field\Wiki\Anime\Theme\Entry;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,10 +21,12 @@ class EntryThemeIdField extends Field implements CreatableField, SelectableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeThemeEntry::ATTRIBUTE_THEME);
|
||||
parent::__construct($schema, AnimeThemeEntry::ATTRIBUTE_THEME);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,10 +47,10 @@ class EntryThemeIdField extends Field implements CreatableField, SelectableField
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match theme relation.
|
||||
return true;
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime\Theme\Entry;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\IntField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class EntryVersionField extends IntField implements CreatableField, UpdatableFie
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeThemeEntry::ATTRIBUTE_VERSION);
|
||||
parent::__construct($schema, AnimeThemeEntry::ATTRIBUTE_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,8 +6,9 @@ namespace App\Http\Api\Field\Wiki\Anime\Theme;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -20,10 +21,12 @@ class ThemeAnimeIdField extends Field implements CreatableField, SelectableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeTheme::ATTRIBUTE_ANIME);
|
||||
parent::__construct($schema, AnimeTheme::ATTRIBUTE_ANIME);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,10 +47,10 @@ class ThemeAnimeIdField extends Field implements CreatableField, SelectableField
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match anime relation.
|
||||
return true;
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime\Theme;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class ThemeGroupField extends StringField implements CreatableField, UpdatableFi
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeTheme::ATTRIBUTE_GROUP);
|
||||
parent::__construct($schema, AnimeTheme::ATTRIBUTE_GROUP);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime\Theme;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\IntField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class ThemeSequenceField extends IntField implements CreatableField, UpdatableFi
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeTheme::ATTRIBUTE_SEQUENCE);
|
||||
parent::__construct($schema, AnimeTheme::ATTRIBUTE_SEQUENCE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Anime\Theme;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class ThemeSlugField extends StringField implements CreatableField, UpdatableFie
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeTheme::ATTRIBUTE_SLUG);
|
||||
parent::__construct($schema, AnimeTheme::ATTRIBUTE_SLUG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,8 +7,9 @@ namespace App\Http\Api\Field\Wiki\Anime\Theme;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\SelectableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use App\Models\Wiki\Song;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -21,10 +22,12 @@ class ThemeSongIdField extends Field implements CreatableField, SelectableField,
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeTheme::ATTRIBUTE_SONG);
|
||||
parent::__construct($schema, AnimeTheme::ATTRIBUTE_SONG);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,10 +49,10 @@ class ThemeSongIdField extends Field implements CreatableField, SelectableField,
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
// Needed to match song relation.
|
||||
return true;
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Models\Wiki\ThemeType;
|
||||
use App\Http\Api\Field\EnumField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use BenSampo\Enum\Rules\EnumValue;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,10 +20,12 @@ class ThemeTypeField extends EnumField implements CreatableField, UpdatableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeTheme::ATTRIBUTE_TYPE, ThemeType::class);
|
||||
parent::__construct($schema, AnimeTheme::ATTRIBUTE_TYPE, ThemeType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Artist;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Pivots\Wiki\ArtistResource;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class ArtistAsField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(ArtistResource::ATTRIBUTE_AS);
|
||||
parent::__construct($schema, ArtistResource::ATTRIBUTE_AS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Artist;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Artist;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class ArtistNameField extends StringField implements CreatableField, UpdatableFi
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Artist::ATTRIBUTE_NAME);
|
||||
parent::__construct($schema, Artist::ATTRIBUTE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Artist;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Artist;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -18,10 +19,12 @@ class ArtistSlugField extends StringField implements CreatableField, UpdatableFi
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Artist::ATTRIBUTE_SLUG);
|
||||
parent::__construct($schema, Artist::ATTRIBUTE_SLUG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,8 +5,9 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Audio;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Wiki\Resource\AudioResource;
|
||||
use App\Models\Wiki\Audio;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -18,10 +19,12 @@ class AudioBasenameField extends StringField implements CreatableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Audio::ATTRIBUTE_BASENAME);
|
||||
parent::__construct($schema, Audio::ATTRIBUTE_BASENAME);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,12 +45,14 @@ class AudioBasenameField extends StringField implements CreatableField
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
$criteria = $query->getFieldCriteria($this->schema->type());
|
||||
|
||||
// The link field is dependent on this field to build the route.
|
||||
return parent::shouldSelect($criteria) || $criteria->isAllowedField(AudioResource::ATTRIBUTE_LINK);
|
||||
return parent::shouldSelect($query) || $criteria->isAllowedField(AudioResource::ATTRIBUTE_LINK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Wiki\Audio;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Audio;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -16,10 +17,12 @@ class AudioFilenameField extends StringField implements CreatableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Audio::ATTRIBUTE_FILENAME);
|
||||
parent::__construct($schema, Audio::ATTRIBUTE_FILENAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Audio;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Wiki\Resource\AudioResource;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class AudioLinkField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AudioResource::ATTRIBUTE_LINK);
|
||||
parent::__construct($schema, AudioResource::ATTRIBUTE_LINK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Wiki\Audio;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Audio;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -16,10 +17,12 @@ class AudioMimeTypeField extends StringField implements CreatableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Audio::ATTRIBUTE_MIMETYPE);
|
||||
parent::__construct($schema, Audio::ATTRIBUTE_MIMETYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Wiki\Audio;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Audio;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -16,10 +17,12 @@ class AudioPathField extends StringField implements CreatableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Audio::ATTRIBUTE_PATH);
|
||||
parent::__construct($schema, Audio::ATTRIBUTE_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Wiki\Audio;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Http\Api\Field\IntField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Audio;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -16,10 +17,12 @@ class AudioSizeField extends IntField implements CreatableField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Audio::ATTRIBUTE_SIZE);
|
||||
parent::__construct($schema, Audio::ATTRIBUTE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Audio;
|
||||
|
||||
use App\Http\Api\Field\CountField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Audio;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class AudioViewCountField extends CountField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Audio::RELATION_VIEWS);
|
||||
parent::__construct($schema, Audio::RELATION_VIEWS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\ExternalResource;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Pivots\Wiki\AnimeResource;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class ExternalResourceAsField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeResource::ATTRIBUTE_AS);
|
||||
parent::__construct($schema, AnimeResource::ATTRIBUTE_AS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\ExternalResource;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\IntField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class ExternalResourceIdField extends IntField implements CreatableField, Updata
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(ExternalResource::ATTRIBUTE_EXTERNAL_ID);
|
||||
parent::__construct($schema, ExternalResource::ATTRIBUTE_EXTERNAL_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Models\Wiki\ResourceSite;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
use App\Rules\Wiki\Resource\ResourceLinkFormatRule;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,10 +20,12 @@ class ExternalResourceLinkField extends StringField implements CreatableField, U
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(ExternalResource::ATTRIBUTE_LINK);
|
||||
parent::__construct($schema, ExternalResource::ATTRIBUTE_LINK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Models\Wiki\ResourceSite;
|
||||
use App\Http\Api\Field\EnumField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\ExternalResource;
|
||||
use App\Rules\Wiki\Resource\ResourceSiteMatchesLinkRule;
|
||||
use BenSampo\Enum\Rules\EnumValue;
|
||||
@@ -20,10 +21,12 @@ class ExternalResourceSiteField extends EnumField implements CreatableField, Upd
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(ExternalResource::ATTRIBUTE_SITE, ResourceSite::class);
|
||||
parent::__construct($schema, ExternalResource::ATTRIBUTE_SITE, ResourceSite::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Enums\Models\Wiki\ImageFacet;
|
||||
use App\Http\Api\Field\EnumField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Image;
|
||||
use BenSampo\Enum\Rules\EnumValue;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -19,10 +20,12 @@ class ImageFacetField extends EnumField implements CreatableField, UpdatableFiel
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Image::ATTRIBUTE_FACET, ImageFacet::class);
|
||||
parent::__construct($schema, Image::ATTRIBUTE_FACET, ImageFacet::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Http\Api\Field\Wiki\Image;
|
||||
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
@@ -17,10 +18,12 @@ class ImageFileField extends Field implements CreatableField
|
||||
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(ImageFileField::ATTRIBUTE_FILE);
|
||||
parent::__construct($schema, ImageFileField::ATTRIBUTE_FILE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Image;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Wiki\Resource\ImageResource;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class ImageLinkField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(ImageResource::ATTRIBUTE_LINK);
|
||||
parent::__construct($schema, ImageResource::ATTRIBUTE_LINK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Api\Field\Wiki\Image;
|
||||
|
||||
use App\Http\Api\Criteria\Field\Criteria;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Query\ReadQuery;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Wiki\Resource\ImageResource;
|
||||
use App\Models\Wiki\Image;
|
||||
|
||||
@@ -16,21 +17,25 @@ class ImagePathField extends StringField
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Image::ATTRIBUTE_PATH);
|
||||
parent::__construct($schema, Image::ATTRIBUTE_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the field should be included in the select clause of our query.
|
||||
*
|
||||
* @param Criteria|null $criteria
|
||||
* @param ReadQuery $query
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSelect(?Criteria $criteria): bool
|
||||
public function shouldSelect(ReadQuery $query): bool
|
||||
{
|
||||
$criteria = $query->getFieldCriteria($this->schema->type());
|
||||
|
||||
// The link field is dependent on this field to build the url.
|
||||
return parent::shouldSelect($criteria) || $criteria->isAllowedField(ImageResource::ATTRIBUTE_LINK);
|
||||
return parent::shouldSelect($query) || $criteria->isAllowedField(ImageResource::ATTRIBUTE_LINK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Search;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Wiki\Collection\AnimeCollection;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class SearchAnimeField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(AnimeCollection::$wrap);
|
||||
parent::__construct($schema, AnimeCollection::$wrap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Search;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Wiki\Collection\ArtistCollection;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class SearchArtistField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(ArtistCollection::$wrap);
|
||||
parent::__construct($schema, ArtistCollection::$wrap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Search;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Wiki\Collection\SeriesCollection;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class SearchSeriesField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(SeriesCollection::$wrap);
|
||||
parent::__construct($schema, SeriesCollection::$wrap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Search;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Wiki\Collection\SongCollection;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class SearchSongField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(SongCollection::$wrap);
|
||||
parent::__construct($schema, SongCollection::$wrap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Search;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Wiki\Collection\StudioCollection;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class SearchStudioField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(StudioCollection::$wrap);
|
||||
parent::__construct($schema, StudioCollection::$wrap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Search;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Wiki\Anime\Collection\ThemeCollection;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class SearchThemeField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(ThemeCollection::$wrap);
|
||||
parent::__construct($schema, ThemeCollection::$wrap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Search;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Wiki\Collection\VideoCollection;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class SearchVideoField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(VideoCollection::$wrap);
|
||||
parent::__construct($schema, VideoCollection::$wrap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Series;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Series;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class SeriesNameField extends StringField implements CreatableField, UpdatableFi
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Series::ATTRIBUTE_NAME);
|
||||
parent::__construct($schema, Series::ATTRIBUTE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Series;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Series;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
@@ -18,10 +19,12 @@ class SeriesSlugField extends StringField implements CreatableField, UpdatableFi
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Series::ATTRIBUTE_SLUG);
|
||||
parent::__construct($schema, Series::ATTRIBUTE_SLUG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Song;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Pivots\Wiki\ArtistSong;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class SongAsField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(ArtistSong::ATTRIBUTE_AS);
|
||||
parent::__construct($schema, ArtistSong::ATTRIBUTE_AS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Http\Api\Field\Wiki\Song;
|
||||
use App\Contracts\Http\Api\Field\CreatableField;
|
||||
use App\Contracts\Http\Api\Field\UpdatableField;
|
||||
use App\Http\Api\Field\StringField;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Models\Wiki\Song;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -17,10 +18,12 @@ class SongTitleField extends StringField implements CreatableField, UpdatableFie
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(Song::ATTRIBUTE_TITLE);
|
||||
parent::__construct($schema, Song::ATTRIBUTE_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Http\Api\Field\Wiki\Studio;
|
||||
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Pivots\Wiki\StudioResource;
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,11 @@ class StudioAsField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct(StudioResource::ATTRIBUTE_AS);
|
||||
parent::__construct($schema, StudioResource::ATTRIBUTE_AS);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user