mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
clean: Removed settings package which is now fully replaced by feature flags (#620)
* clean: Removed settings package which is now fully replaced by feature flags * clean: Remove left-over config values
This commit is contained in:
@@ -295,7 +295,5 @@ WEB_URL=http://localhost
|
||||
WEB_PATH=
|
||||
|
||||
# wiki
|
||||
WIKI_FEATURED_ENTRY=
|
||||
WIKI_FEATURED_VIDEO=
|
||||
WIKI_LOGIN=http://localhost/login
|
||||
WIKI_RESET_PASSWORD=http://localhost/reset-password
|
||||
|
||||
@@ -296,7 +296,5 @@ WEB_URL=http://localhost
|
||||
WEB_PATH=
|
||||
|
||||
# wiki
|
||||
WIKI_FEATURED_ENTRY=
|
||||
WIKI_FEATURED_VIDEO=
|
||||
WIKI_LOGIN=http://localhost/login
|
||||
WIKI_RESET_PASSWORD=http://localhost/reset-password
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Constants\Config;
|
||||
|
||||
/**
|
||||
* Class WikiConstants.
|
||||
*/
|
||||
class WikiConstants
|
||||
{
|
||||
final public const FEATURED_ENTRY_SETTING = 'featured_entry';
|
||||
|
||||
final public const FEATURED_ENTRY_SETTING_QUALIFIED = 'wiki.featured_entry';
|
||||
|
||||
final public const FEATURED_THEME_SETTING = 'featured_theme';
|
||||
|
||||
final public const FEATURED_VIDEO_SETTING = 'featured_video';
|
||||
|
||||
final public const FEATURED_VIDEO_SETTING_QUALIFIED = 'wiki.featured_video';
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Events\Admin\Setting;
|
||||
|
||||
use App\Enums\Discord\EmbedColor;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use NotificationChannels\Discord\DiscordMessage;
|
||||
|
||||
/**
|
||||
* Class SettingCreated.
|
||||
*/
|
||||
class SettingCreated extends SettingEvent
|
||||
{
|
||||
use Dispatchable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* Get Discord message payload.
|
||||
*
|
||||
* @return DiscordMessage
|
||||
*/
|
||||
public function getDiscordMessage(): DiscordMessage
|
||||
{
|
||||
$setting = $this->getSetting();
|
||||
|
||||
return DiscordMessage::create('', [
|
||||
'description' => "Setting '**{$setting->getName()}**' has been created.",
|
||||
'color' => EmbedColor::GREEN->value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Events\Admin\Setting;
|
||||
|
||||
use App\Enums\Discord\EmbedColor;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use NotificationChannels\Discord\DiscordMessage;
|
||||
|
||||
/**
|
||||
* Class SettingDeleted.
|
||||
*/
|
||||
class SettingDeleted extends SettingEvent
|
||||
{
|
||||
use Dispatchable;
|
||||
|
||||
/**
|
||||
* Get Discord message payload.
|
||||
*
|
||||
* @return DiscordMessage
|
||||
*/
|
||||
public function getDiscordMessage(): DiscordMessage
|
||||
{
|
||||
$setting = $this->getSetting();
|
||||
|
||||
return DiscordMessage::create('', [
|
||||
'description' => "Setting '**{$setting->getName()}**' has been deleted.",
|
||||
'color' => EmbedColor::RED->value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Events\Admin\Setting;
|
||||
|
||||
use App\Constants\Config\ServiceConstants;
|
||||
use App\Contracts\Events\DiscordMessageEvent;
|
||||
use App\Models\Admin\Setting;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
/**
|
||||
* Class SettingEvent.
|
||||
*/
|
||||
abstract class SettingEvent implements DiscordMessageEvent
|
||||
{
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param Setting $setting
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(protected Setting $setting)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the setting that has fired this event.
|
||||
*
|
||||
* @return Setting
|
||||
*/
|
||||
public function getSetting(): Setting
|
||||
{
|
||||
return $this->setting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Discord channel the message will be sent to.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscordChannel(): string
|
||||
{
|
||||
return Config::get(ServiceConstants::ADMIN_DISCORD_CHANNEL_QUALIFIED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the message should be sent.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function shouldSendDiscordMessage(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Events\Admin\Setting;
|
||||
|
||||
use App\Concerns\Discord\HasAttributeUpdateEmbedFields;
|
||||
use App\Enums\Discord\EmbedColor;
|
||||
use App\Models\Admin\Setting;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use NotificationChannels\Discord\DiscordMessage;
|
||||
|
||||
/**
|
||||
* Class SettingUpdated.
|
||||
*/
|
||||
class SettingUpdated extends SettingEvent
|
||||
{
|
||||
use Dispatchable;
|
||||
use HasAttributeUpdateEmbedFields;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param Setting $setting
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Setting $setting)
|
||||
{
|
||||
parent::__construct($setting);
|
||||
$this->initializeEmbedFields($setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Discord message payload.
|
||||
*
|
||||
* @return DiscordMessage
|
||||
*/
|
||||
public function getDiscordMessage(): DiscordMessage
|
||||
{
|
||||
$setting = $this->getSetting();
|
||||
|
||||
return DiscordMessage::create('', [
|
||||
'description' => "Setting '**{$setting->getName()}**' has been updated.",
|
||||
'fields' => $this->getEmbedFields(),
|
||||
'color' => EmbedColor::YELLOW->value,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
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.
|
||||
*/
|
||||
class WikiFeaturedThemeField extends Field
|
||||
{
|
||||
/**
|
||||
* Create a new field instance.
|
||||
*
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function __construct(Schema $schema)
|
||||
{
|
||||
parent::__construct($schema, WikiConstants::FEATURED_THEME_SETTING);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Api\Schema\Config;
|
||||
|
||||
use App\Http\Api\Field\Config\Wiki\WikiFeaturedThemeField;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Include\AllowedInclude;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Resources\Config\Resource\WikiResource;
|
||||
|
||||
/**
|
||||
* Class WikiSchema.
|
||||
*/
|
||||
class WikiSchema extends Schema
|
||||
{
|
||||
/**
|
||||
* Get the type of the resource.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function type(): string
|
||||
{
|
||||
return WikiResource::$wrap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the allowed includes.
|
||||
*
|
||||
* @return AllowedInclude[]
|
||||
*/
|
||||
public function allowedIncludes(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the direct fields of the resource.
|
||||
*
|
||||
* @return Field[]
|
||||
*
|
||||
* @noinspection PhpMissingParentCallCommonInspection
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
new WikiFeaturedThemeField($this),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\Config;
|
||||
|
||||
use App\Contracts\Http\Api\InteractsWithSchema;
|
||||
use App\Http\Api\Query\Query;
|
||||
use App\Http\Api\Schema\Config\WikiSchema;
|
||||
use App\Http\Api\Schema\Schema;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Api\ShowRequest;
|
||||
use App\Http\Resources\Config\Resource\WikiResource;
|
||||
|
||||
/**
|
||||
* Class WikiController.
|
||||
*/
|
||||
class WikiController extends Controller implements InteractsWithSchema
|
||||
{
|
||||
/**
|
||||
* Wiki resource.
|
||||
*
|
||||
* @param ShowRequest $request
|
||||
* @return WikiResource
|
||||
*/
|
||||
public function show(ShowRequest $request): WikiResource
|
||||
{
|
||||
$query = new Query($request->validated());
|
||||
|
||||
return new WikiResource($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying schema.
|
||||
*
|
||||
* @return Schema
|
||||
*/
|
||||
public function schema(): Schema
|
||||
{
|
||||
return new WikiSchema();
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\Config\Resource;
|
||||
|
||||
use App\Constants\Config\WikiConstants;
|
||||
use App\Http\Api\Query\Query;
|
||||
use App\Http\Resources\Pivot\Wiki\Resource\AnimeThemeEntryVideoResource;
|
||||
use App\Pivots\Wiki\AnimeThemeEntryVideo;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Http\Resources\MissingValue;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
/**
|
||||
* Class WikiResource.
|
||||
*/
|
||||
class WikiResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* The "data" wrapper that should be applied.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public static $wrap = 'wiki';
|
||||
|
||||
/**
|
||||
* Create a new resource instance.
|
||||
*
|
||||
* @param Query $query
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(protected readonly Query $query)
|
||||
{
|
||||
parent::__construct(new MissingValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return array
|
||||
*
|
||||
* @noinspection PhpMissingParentCallCommonInspection
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$criteria = $this->query->getFieldCriteria(static::$wrap);
|
||||
|
||||
if ($criteria === null || $criteria->isAllowedField(WikiConstants::FEATURED_THEME_SETTING)) {
|
||||
/** @var AnimeThemeEntryVideo|null $pivot */
|
||||
$pivot = AnimeThemeEntryVideo::query()
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_ENTRY, Config::get('wiki.featured_entry'))
|
||||
->where(AnimeThemeEntryVideo::ATTRIBUTE_VIDEO, Config::get('wiki.featured_video'))
|
||||
->with([
|
||||
AnimeThemeEntryVideo::RELATION_ANIME,
|
||||
AnimeThemeEntryVideo::RELATION_ARTISTS,
|
||||
AnimeThemeEntryVideo::RELATION_IMAGES,
|
||||
AnimeThemeEntryVideo::RELATION_SONG,
|
||||
AnimeThemeEntryVideo::RELATION_VIDEO,
|
||||
])
|
||||
->first();
|
||||
|
||||
$result[WikiConstants::FEATURED_THEME_SETTING] = new AnimeThemeEntryVideoResource($pivot, $this->query);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models\Admin;
|
||||
|
||||
use App\Contracts\Models\Nameable;
|
||||
use App\Events\Admin\Setting\SettingCreated;
|
||||
use App\Events\Admin\Setting\SettingDeleted;
|
||||
use App\Events\Admin\Setting\SettingUpdated;
|
||||
use Database\Factories\Admin\SettingFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Laravel\Nova\Actions\Actionable;
|
||||
|
||||
/**
|
||||
* Class Setting.
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $key
|
||||
* @property string $value
|
||||
*
|
||||
* @method static SettingFactory factory(...$parameters)
|
||||
*/
|
||||
class Setting extends Model implements Nameable
|
||||
{
|
||||
use Actionable;
|
||||
use HasFactory;
|
||||
|
||||
final public const TABLE = 'settings';
|
||||
|
||||
final public const ATTRIBUTE_KEY = 'key';
|
||||
final public const ATTRIBUTE_ID = 'id';
|
||||
final public const ATTRIBUTE_VALUE = 'value';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $fillable = [
|
||||
Setting::ATTRIBUTE_KEY,
|
||||
Setting::ATTRIBUTE_VALUE,
|
||||
];
|
||||
|
||||
/**
|
||||
* The event map for the model.
|
||||
*
|
||||
* Allows for object-based events for native Eloquent events.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dispatchesEvents = [
|
||||
'created' => SettingCreated::class,
|
||||
'deleted' => SettingDeleted::class,
|
||||
'updated' => SettingUpdated::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = Setting::TABLE;
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = Setting::ATTRIBUTE_ID;
|
||||
|
||||
/**
|
||||
* Get name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Nova\Resources\Admin;
|
||||
|
||||
use App\Models\Admin\Setting as SettingModel;
|
||||
use App\Nova\Resources\BaseResource;
|
||||
use Exception;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use Laravel\Nova\Query\Search\Column;
|
||||
|
||||
/**
|
||||
* Class Setting.
|
||||
*/
|
||||
class Setting extends BaseResource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static string $model = SettingModel::class;
|
||||
|
||||
/**
|
||||
* The single value that should be used to represent the resource when being displayed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $title = SettingModel::ATTRIBUTE_KEY;
|
||||
|
||||
/**
|
||||
* The logical group associated with the resource.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @noinspection PhpMissingParentCallCommonInspection
|
||||
*/
|
||||
public static function group(): string
|
||||
{
|
||||
return __('nova.resources.group.admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable label of the resource.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @noinspection PhpMissingParentCallCommonInspection
|
||||
*/
|
||||
public static function label(): string
|
||||
{
|
||||
return __('nova.resources.label.settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the displayable singular label of the resource.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @noinspection PhpMissingParentCallCommonInspection
|
||||
*/
|
||||
public static function singularLabel(): string
|
||||
{
|
||||
return __('nova.resources.singularLabel.setting');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the searchable columns for the resource.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @noinspection PhpMissingParentCallCommonInspection
|
||||
*/
|
||||
public static function searchableColumns(): array
|
||||
{
|
||||
return [
|
||||
new Column(SettingModel::ATTRIBUTE_KEY),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the resource should be globally searchable.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public static $globallySearchable = false;
|
||||
|
||||
/**
|
||||
* Determine if this resource uses Laravel Scout.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @noinspection PhpMissingParentCallCommonInspection
|
||||
*/
|
||||
public static function usesScout(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*
|
||||
* @param NovaRequest $request
|
||||
* @return array
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
ID::make(__('nova.fields.base.id'), SettingModel::ATTRIBUTE_ID)
|
||||
->sortable()
|
||||
->showOnPreview()
|
||||
->showWhenPeeking(),
|
||||
|
||||
Text::make(__('nova.fields.setting.key'), SettingModel::ATTRIBUTE_KEY)
|
||||
->sortable()
|
||||
->copyable()
|
||||
->rules(['required', 'max:192'])
|
||||
->showOnPreview()
|
||||
->filterable()
|
||||
->maxlength(192)
|
||||
->enforceMaxlength()
|
||||
->showWhenPeeking(),
|
||||
|
||||
Text::make(__('nova.fields.setting.value'), SettingModel::ATTRIBUTE_VALUE)
|
||||
->sortable()
|
||||
->copyable()
|
||||
->rules(['required', 'max:65535'])
|
||||
->showOnPreview()
|
||||
->filterable()
|
||||
->maxlength(65535)
|
||||
->enforceMaxlength()
|
||||
->showWhenPeeking(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Policies\Admin;
|
||||
|
||||
use App\Enums\Auth\CrudPermission;
|
||||
use App\Models\Admin\Setting;
|
||||
use App\Models\Auth\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Class SettingPolicy.
|
||||
*/
|
||||
class SettingPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @param User $user
|
||||
* @return bool
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->can(CrudPermission::VIEW->format(Setting::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the model.
|
||||
*
|
||||
* @param User $user
|
||||
* @return bool
|
||||
*/
|
||||
public function view(User $user): bool
|
||||
{
|
||||
return $user->can(CrudPermission::VIEW->format(Setting::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create models.
|
||||
*
|
||||
* @param User $user
|
||||
* @return bool
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->can(CrudPermission::CREATE->format(Setting::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can update the model.
|
||||
*
|
||||
* @param User $user
|
||||
* @return bool
|
||||
*/
|
||||
public function update(User $user): bool
|
||||
{
|
||||
return $user->can(CrudPermission::UPDATE->format(Setting::class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param User $user
|
||||
* @return bool
|
||||
*/
|
||||
public function delete(User $user): bool
|
||||
{
|
||||
return $user->can(CrudPermission::DELETE->format(Setting::class));
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@
|
||||
"ext-gd": "*",
|
||||
"ext-intl": "*",
|
||||
"ext-pdo": "*",
|
||||
"akaunting/laravel-setting": "^1.2",
|
||||
"babenkoivan/elastic-migrations": "^3.3",
|
||||
"babenkoivan/elastic-scout-driver-plus": "^4.3",
|
||||
"bepsvpt/secure-headers": "^7.4",
|
||||
|
||||
Generated
+2
-69
@@ -4,75 +4,8 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "279efd9eda924e0365bf45eb667d29ad",
|
||||
"content-hash": "dfa287f156f616dad184bfc915642153",
|
||||
"packages": [
|
||||
{
|
||||
"name": "akaunting/laravel-setting",
|
||||
"version": "1.2.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/akaunting/laravel-setting.git",
|
||||
"reference": "598cacc042cb5081366f03e5229edbe2a2f17cdf"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/akaunting/laravel-setting/zipball/598cacc042cb5081366f03e5229edbe2a2f17cdf",
|
||||
"reference": "598cacc042cb5081366f03e5229edbe2a2f17cdf",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"laravel/framework": ">=5.3",
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/framework": ">=5.3",
|
||||
"mockery/mockery": "0.9.*",
|
||||
"phpunit/phpunit": ">=4.8"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Akaunting\\Setting\\Provider"
|
||||
],
|
||||
"aliases": {
|
||||
"Setting": "Akaunting\\Setting\\Facade"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Akaunting\\Setting\\": "./src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Denis Duliçi",
|
||||
"email": "info@akaunting.com",
|
||||
"homepage": "https://akaunting.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Persistent settings package for Laravel",
|
||||
"keywords": [
|
||||
"Settings",
|
||||
"config",
|
||||
"laravel",
|
||||
"persistent"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/akaunting/laravel-setting/issues",
|
||||
"source": "https://github.com/akaunting/laravel-setting/tree/1.2.8"
|
||||
},
|
||||
"time": "2022-09-23T10:56:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "aws/aws-crt-php",
|
||||
"version": "v1.2.1",
|
||||
@@ -12260,5 +12193,5 @@
|
||||
"ext-pcntl": "8.2",
|
||||
"ext-posix": "8.2"
|
||||
},
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Constants\Config\WikiConstants;
|
||||
use App\Models\Admin\Setting;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable / Disable auto save
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Auto-save every time the application shuts down
|
||||
|
|
||||
*/
|
||||
'auto_save' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Options for caching. Set whether to enable cache, its key, time to live
|
||||
| in seconds and whether to auto clear after save.
|
||||
|
|
||||
*/
|
||||
'cache' => [
|
||||
'enabled' => false,
|
||||
'key' => 'setting',
|
||||
'ttl' => 3600,
|
||||
'auto_clear' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Setting driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Select where to store the settings.
|
||||
|
|
||||
| Supported: "database", "json", "memory"
|
||||
|
|
||||
*/
|
||||
'driver' => 'database',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Options for database driver. Enter which connection to use, null means
|
||||
| the default connection. Set the table and column names.
|
||||
|
|
||||
*/
|
||||
'database' => [
|
||||
'connection' => null,
|
||||
'table' => Setting::TABLE,
|
||||
'key' => Setting::ATTRIBUTE_KEY,
|
||||
'value' => Setting::ATTRIBUTE_VALUE,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| JSON driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Options for json driver. Enter the full path to the .json file.
|
||||
|
|
||||
*/
|
||||
'json' => [
|
||||
'path' => storage_path().'/settings.json',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Override application config values
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If defined, settings package will override these config values.
|
||||
|
|
||||
| Sample:
|
||||
| "app.locale" => "settings.locale",
|
||||
|
|
||||
*/
|
||||
'override' => [
|
||||
WikiConstants::FEATURED_ENTRY_SETTING_QUALIFIED => WikiConstants::FEATURED_ENTRY_SETTING,
|
||||
WikiConstants::FEATURED_VIDEO_SETTING_QUALIFIED => WikiConstants::FEATURED_VIDEO_SETTING,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Fallback
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Define fallback settings to be used in case the default is null
|
||||
|
|
||||
| Sample:
|
||||
| "currency" => "USD",
|
||||
|
|
||||
*/
|
||||
'fallback' => [
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Required Extra Columns
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The list of columns required to be set up
|
||||
|
|
||||
| Sample:
|
||||
| "user_id",
|
||||
| "tenant_id",
|
||||
|
|
||||
*/
|
||||
'required_extra_columns' => [
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Define the keys which should be crypt automatically.
|
||||
|
|
||||
| Sample:
|
||||
| "payment.key"
|
||||
|
|
||||
*/
|
||||
'encrypted_keys' => [
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
@@ -4,23 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Featured Theme
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| On the home page of the wiki client, there is a component for a featured theme.
|
||||
| The featured theme will showcase an OP/ED picked by staff or patrons.
|
||||
| The video for the featured theme will play muted, blurred and looped in the background of the page.
|
||||
| To resolve the featured theme, we need to provide the desired pivot row between entry and video.
|
||||
| To resolve the desired pivot row, these values should correspond to the primary keys of the respective models.
|
||||
|
|
||||
*/
|
||||
|
||||
'featured_entry' => (int) env('WIKI_FEATURED_ENTRY'),
|
||||
|
||||
'featured_video' => (int) env('WIKI_FEATURED_VIDEO'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Wiki Routes
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories\Admin;
|
||||
|
||||
use App\Models\Admin\Setting;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* Class SettingFactory.
|
||||
*
|
||||
* @method Setting createOne($attributes = [])
|
||||
* @method Setting makeOne($attributes = [])
|
||||
*
|
||||
* @extends Factory<Setting>
|
||||
*/
|
||||
class SettingFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var class-string<Setting>
|
||||
*/
|
||||
protected $model = Setting::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
Setting::ATTRIBUTE_KEY => fake()->slug(),
|
||||
Setting::ATTRIBUTE_VALUE => fake()->word(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Models\Admin\Setting;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable(Setting::TABLE)) {
|
||||
Schema::create(Setting::TABLE, function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string(Setting::ATTRIBUTE_KEY)->index();
|
||||
$table->text(Setting::ATTRIBUTE_VALUE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists(Setting::TABLE);
|
||||
}
|
||||
};
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders\Admin\Setting;
|
||||
|
||||
use App\Constants\Config\WikiConstants;
|
||||
use App\Models\Admin\Setting;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
/**
|
||||
* Class SettingSeeder.
|
||||
*/
|
||||
class SettingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
Setting::query()->firstOrCreate(
|
||||
[
|
||||
Setting::ATTRIBUTE_KEY => WikiConstants::FEATURED_ENTRY_SETTING,
|
||||
],
|
||||
[
|
||||
Setting::ATTRIBUTE_KEY => WikiConstants::FEATURED_ENTRY_SETTING,
|
||||
Setting::ATTRIBUTE_VALUE => Config::get(WikiConstants::FEATURED_ENTRY_SETTING_QUALIFIED, ''),
|
||||
]
|
||||
);
|
||||
|
||||
Setting::query()->firstOrCreate(
|
||||
[
|
||||
Setting::ATTRIBUTE_KEY => WikiConstants::FEATURED_VIDEO_SETTING,
|
||||
],
|
||||
[
|
||||
Setting::ATTRIBUTE_KEY => WikiConstants::FEATURED_VIDEO_SETTING,
|
||||
Setting::ATTRIBUTE_VALUE => Config::get(WikiConstants::FEATURED_VIDEO_SETTING_QUALIFIED, ''),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ use App\Models\Admin\Announcement;
|
||||
use App\Models\Admin\Dump;
|
||||
use App\Models\Admin\Feature;
|
||||
use App\Models\Admin\FeaturedTheme;
|
||||
use App\Models\Admin\Setting;
|
||||
use App\Models\Auth\Permission;
|
||||
use App\Models\Auth\Role;
|
||||
use App\Models\Auth\User;
|
||||
@@ -53,7 +52,6 @@ class PermissionSeeder extends Seeder
|
||||
// Admin Resources
|
||||
$this->registerResource(Announcement::class, $extendedCrudPermissions);
|
||||
$this->registerResource(Dump::class, $extendedCrudPermissions);
|
||||
$this->registerResource(Setting::class, CrudPermission::cases());
|
||||
$this->registerResource(Feature::class, CrudPermission::cases());
|
||||
$this->registerResource(FeaturedTheme::class, $extendedCrudPermissions);
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ use App\Models\Admin\Announcement;
|
||||
use App\Models\Admin\Dump;
|
||||
use App\Models\Admin\Feature;
|
||||
use App\Models\Admin\FeaturedTheme;
|
||||
use App\Models\Admin\Setting;
|
||||
use App\Models\Auth\Permission;
|
||||
use App\Models\Auth\Role;
|
||||
use App\Models\Auth\User;
|
||||
@@ -58,7 +57,6 @@ class AdminSeeder extends RoleSeeder
|
||||
$this->configureResource($role, Announcement::class, $extendedCrudPermissions);
|
||||
$this->configureResource($role, Dump::class, $extendedCrudPermissions);
|
||||
$this->configureResource($role, Feature::class, [CrudPermission::VIEW, CrudPermission::UPDATE]);
|
||||
$this->configureResource($role, Setting::class, CrudPermission::cases());
|
||||
$this->configureResource($role, FeaturedTheme::class, $extendedCrudPermissions);
|
||||
|
||||
// Auth Resources
|
||||
|
||||
@@ -657,10 +657,6 @@ return [
|
||||
'name' => 'Slug',
|
||||
],
|
||||
],
|
||||
'setting' => [
|
||||
'key' => 'Key',
|
||||
'value' => 'Value',
|
||||
],
|
||||
'song' => [
|
||||
'title' => [
|
||||
'help' => 'The title of the song',
|
||||
|
||||
@@ -9,7 +9,6 @@ use App\Http\Controllers\Api\Admin\FeatureController;
|
||||
use App\Http\Controllers\Api\Admin\FeaturedThemeController;
|
||||
use App\Http\Controllers\Api\Auth\User\Me\List\MyPlaylistController;
|
||||
use App\Http\Controllers\Api\Auth\User\Me\MyController;
|
||||
use App\Http\Controllers\Api\Config\WikiController;
|
||||
use App\Http\Controllers\Api\Document\PageController;
|
||||
use App\Http\Controllers\Api\List\Playlist\TrackBackwardController;
|
||||
use App\Http\Controllers\Api\List\Playlist\TrackController;
|
||||
@@ -232,9 +231,6 @@ Route::apiResource('feature', FeatureController::class)
|
||||
Route::get('/me', [MyController::class, 'show'])->name('me.show');
|
||||
Route::get('/me/playlist', [MyPlaylistController::class, 'index'])->name('me.playlist.index');
|
||||
|
||||
// Config Routes
|
||||
Route::get('config/wiki', [WikiController::class, 'show'])->name('config.wiki.show');
|
||||
|
||||
// Document Routes
|
||||
apiResourceWhere('page', PageController::class, ['page' => '[\pL\pM\pN\/_-]+']);
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Events\Admin;
|
||||
|
||||
use App\Events\Admin\Setting\SettingCreated;
|
||||
use App\Events\Admin\Setting\SettingDeleted;
|
||||
use App\Events\Admin\Setting\SettingUpdated;
|
||||
use App\Models\Admin\Setting;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class SettingTest.
|
||||
*/
|
||||
class SettingTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* When a Setting is created, a SettingCreated event shall be dispatched.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSettingCreatedEventDispatched(): void
|
||||
{
|
||||
Setting::factory()->create();
|
||||
|
||||
Event::assertDispatched(SettingCreated::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a Setting is deleted, a SettingDeleted event shall be dispatched.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSettingDeletedEventDispatched(): void
|
||||
{
|
||||
$setting = Setting::factory()->create();
|
||||
|
||||
$setting->delete();
|
||||
|
||||
Event::assertDispatched(SettingDeleted::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a Setting is updated, a SettingUpdated event shall be dispatched.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSettingUpdatedEventDispatched(): void
|
||||
{
|
||||
$setting = Setting::factory()->createOne();
|
||||
$changes = Setting::factory()->makeOne();
|
||||
|
||||
$setting->fill($changes->getAttributes());
|
||||
$setting->save();
|
||||
|
||||
Event::assertDispatched(SettingUpdated::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The SettingUpdated event shall contain embed fields.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSettingUpdatedEventEmbedFields(): void
|
||||
{
|
||||
$setting = Setting::factory()->createOne();
|
||||
$changes = Setting::factory()->makeOne();
|
||||
|
||||
$setting->fill($changes->getAttributes());
|
||||
$setting->save();
|
||||
|
||||
Event::assertDispatched(SettingUpdated::class, function (SettingUpdated $event) {
|
||||
$message = $event->getDiscordMessage();
|
||||
|
||||
return ! empty(Arr::get($message->embed, 'fields'));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Http\Api\Config;
|
||||
|
||||
use App\Constants\Config\WikiConstants;
|
||||
use App\Http\Api\Field\Field;
|
||||
use App\Http\Api\Parser\FieldParser;
|
||||
use App\Http\Api\Query\Query;
|
||||
use App\Http\Api\Schema\Config\WikiSchema;
|
||||
use App\Http\Resources\Config\Resource\WikiResource;
|
||||
use App\Models\Wiki\Anime;
|
||||
use App\Models\Wiki\Anime\AnimeTheme;
|
||||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
||||
use App\Models\Wiki\Video;
|
||||
use App\Pivots\Wiki\AnimeThemeEntryVideo;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class WikiShowTest.
|
||||
*/
|
||||
class WikiShowTest extends TestCase
|
||||
{
|
||||
use WithFaker;
|
||||
|
||||
/**
|
||||
* By default, the Wiki Show Endpoint shall return a Wiki Resource.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDefault(): void
|
||||
{
|
||||
$pivot = AnimeThemeEntryVideo::factory()
|
||||
->for(Video::factory())
|
||||
->for(AnimeThemeEntry::factory()->for(AnimeTheme::factory()->for(Anime::factory())))
|
||||
->createOne();
|
||||
|
||||
Config::set(WikiConstants::FEATURED_ENTRY_SETTING_QUALIFIED, $pivot->entry_id);
|
||||
Config::set(WikiConstants::FEATURED_VIDEO_SETTING_QUALIFIED, $pivot->video_id);
|
||||
|
||||
$response = $this->get(route('api.config.wiki.show'));
|
||||
|
||||
$response->assertJson(
|
||||
json_decode(
|
||||
json_encode(
|
||||
(new WikiResource(new Query()))
|
||||
->response()
|
||||
->getData()
|
||||
),
|
||||
true
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Wiki Show Endpoint shall implement sparse fieldsets.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSparseFieldsets(): void
|
||||
{
|
||||
$pivot = AnimeThemeEntryVideo::factory()
|
||||
->for(Video::factory())
|
||||
->for(AnimeThemeEntry::factory()->for(AnimeTheme::factory()->for(Anime::factory())))
|
||||
->createOne();
|
||||
|
||||
Config::set(WikiConstants::FEATURED_ENTRY_SETTING_QUALIFIED, $pivot->entry_id);
|
||||
Config::set(WikiConstants::FEATURED_VIDEO_SETTING_QUALIFIED, $pivot->video_id);
|
||||
|
||||
$schema = new WikiSchema();
|
||||
|
||||
$fields = collect($schema->fields());
|
||||
|
||||
$includedFields = $fields->random($this->faker->numberBetween(1, $fields->count()));
|
||||
|
||||
$parameters = [
|
||||
FieldParser::param() => [
|
||||
WikiResource::$wrap => $includedFields->map(fn (Field $field) => $field->getKey())->join(','),
|
||||
],
|
||||
];
|
||||
|
||||
$response = $this->get(route('api.config.wiki.show'));
|
||||
|
||||
$response->assertJson(
|
||||
json_decode(
|
||||
json_encode(
|
||||
(new WikiResource(new Query($parameters)))
|
||||
->response()
|
||||
->getData()
|
||||
),
|
||||
true
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Jobs\Admin;
|
||||
|
||||
use App\Constants\FeatureConstants;
|
||||
use App\Events\Admin\Setting\SettingCreated;
|
||||
use App\Events\Admin\Setting\SettingDeleted;
|
||||
use App\Events\Admin\Setting\SettingUpdated;
|
||||
use App\Jobs\SendDiscordNotificationJob;
|
||||
use App\Models\Admin\Setting;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Laravel\Pennant\Feature;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class SettingTest.
|
||||
*/
|
||||
class SettingTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* When a setting is created, a SendDiscordNotification job shall be dispatched.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSettingCreatedSendsDiscordNotification(): void
|
||||
{
|
||||
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
||||
Bus::fake(SendDiscordNotificationJob::class);
|
||||
Event::fakeExcept(SettingCreated::class);
|
||||
|
||||
Setting::factory()->createOne();
|
||||
|
||||
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a setting is deleted, a SendDiscordNotification job shall be dispatched.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSettingDeletedSendsDiscordNotification(): void
|
||||
{
|
||||
$setting = Setting::factory()->createOne();
|
||||
|
||||
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
||||
Bus::fake(SendDiscordNotificationJob::class);
|
||||
Event::fakeExcept(SettingDeleted::class);
|
||||
|
||||
$setting->delete();
|
||||
|
||||
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a setting is updated, a SendDiscordNotification job shall be dispatched.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testSettingUpdatedSendsDiscordNotification(): void
|
||||
{
|
||||
$setting = Setting::factory()->createOne();
|
||||
|
||||
Feature::activate(FeatureConstants::ALLOW_DISCORD_NOTIFICATIONS);
|
||||
Bus::fake(SendDiscordNotificationJob::class);
|
||||
Event::fakeExcept(SettingUpdated::class);
|
||||
|
||||
$changes = Setting::factory()->makeOne();
|
||||
|
||||
$setting->fill($changes->getAttributes());
|
||||
$setting->save();
|
||||
|
||||
Bus::assertDispatched(SendDiscordNotificationJob::class);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Models\Admin;
|
||||
|
||||
use App\Models\Admin\Setting;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class SettingTest.
|
||||
*/
|
||||
class SettingTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Settings shall be nameable.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNameable(): void
|
||||
{
|
||||
$setting = Setting::factory()->createOne();
|
||||
|
||||
static::assertIsString($setting->getName());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user