Files
animethemes-server/app/Http/Resources/Config/Resource/FlagsResource.php
T
paranarimasu 8b6b196c99 feat(admin): migrate db dumps from github to platform (#465)
* feat: migrate encoding scripts from github to platform

* style: fix StyleCI finding

* fix: don't concatenate updated videos when attempting to attach entry on video upload

* fix(api): fix field dependencies & feat(admin): upload script from video detail screen
2022-09-24 00:01:37 -05:00

76 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Http\Resources\Config\Resource;
use App\Constants\Config\FlagConstants;
use App\Http\Api\Query\ReadQuery;
use App\Http\Resources\BaseResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\MissingValue;
use Illuminate\Support\Facades\Config;
/**
* Class FlagsResource.
*/
class FlagsResource extends BaseResource
{
/**
* The "data" wrapper that should be applied.
*
* @var string|null
*/
public static $wrap = 'flags';
/**
* Create a new resource instance.
*
* @param ReadQuery $query
* @return void
*/
public function __construct(ReadQuery $query)
{
parent::__construct(new MissingValue(), $query);
}
/**
* Transform the resource into an array.
*
* @param Request $request
* @return array
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public function toArray($request): array
{
$result = [];
if ($this->isAllowedField(FlagConstants::ALLOW_VIDEO_STREAMS_FLAG)) {
$result[FlagConstants::ALLOW_VIDEO_STREAMS_FLAG] = Config::bool(FlagConstants::ALLOW_VIDEO_STREAMS_FLAG_QUALIFIED);
}
if ($this->isAllowedField(FlagConstants::ALLOW_AUDIO_STREAMS_FLAG)) {
$result[FlagConstants::ALLOW_AUDIO_STREAMS_FLAG] = Config::bool(FlagConstants::ALLOW_AUDIO_STREAMS_FLAG_QUALIFIED);
}
if ($this->isAllowedField(FlagConstants::ALLOW_DISCORD_NOTIFICATIONS_FLAG)) {
$result[FlagConstants::ALLOW_DISCORD_NOTIFICATIONS_FLAG] = Config::bool(FlagConstants::ALLOW_DISCORD_NOTIFICATIONS_FLAG_QUALIFIED);
}
if ($this->isAllowedField(FlagConstants::ALLOW_VIEW_RECORDING_FLAG)) {
$result[FlagConstants::ALLOW_VIEW_RECORDING_FLAG] = Config::bool(FlagConstants::ALLOW_VIEW_RECORDING_FLAG_QUALIFIED);
}
if ($this->isAllowedField(FlagConstants::ALLOW_DUMP_DOWNLOADING_FLAG)) {
$result[FlagConstants::ALLOW_DUMP_DOWNLOADING_FLAG] = Config::bool(FlagConstants::ALLOW_DUMP_DOWNLOADING_FLAG_QUALIFIED);
}
if ($this->isAllowedField(FlagConstants::ALLOW_SCRIPT_DOWNLOADING_FLAG)) {
$result[FlagConstants::ALLOW_SCRIPT_DOWNLOADING_FLAG] = Config::bool(FlagConstants::ALLOW_SCRIPT_DOWNLOADING_FLAG_QUALIFIED);
}
return $result;
}
}