Skip to content

Commit

Permalink
feat(filament): added entries tab to create theme form (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Jun 21, 2024
1 parent 41e4a90 commit 847189a
Show file tree
Hide file tree
Showing 44 changed files with 617 additions and 788 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function getOrCreateResource(mixed $externalLink): ExternalResource
$urlPattern = $resourceSite->getUrlCaptureGroups($this->getModel());

if (preg_match($urlPattern, $url, $matches)) {
$url = $resourceSite->formatAnimeResourceLink(intval($matches[2]), $matches[2], $matches[1]);
$url = $resourceSite->formatResourceLink(Anime::class, intval($matches[2]), $matches[2], $matches[1]);
}

$resource = ExternalResource::query()
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Models/Wiki/Anime/BackfillAnimeResourceAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ protected function getOrCreateResource(int $id, string $slug = null): ExternalRe
$resource = ExternalResource::query()
->where(ExternalResource::ATTRIBUTE_SITE, $this->getSite()->value)
->where(ExternalResource::ATTRIBUTE_EXTERNAL_ID, $id)
->where(ExternalResource::ATTRIBUTE_LINK, $this->getSite()->formatAnimeResourceLink($id, $slug))
->where(ExternalResource::ATTRIBUTE_LINK, $this->getSite()->formatResourceLink(Anime::class, $id, $slug))
->first();

if ($resource === null) {
Log::info("Creating {$this->getSite()->localize()} Resource '$id'");

$resource = ExternalResource::query()->create([
ExternalResource::ATTRIBUTE_EXTERNAL_ID => $id,
ExternalResource::ATTRIBUTE_LINK => $this->getSite()->formatAnimeResourceLink($id, $slug),
ExternalResource::ATTRIBUTE_LINK => $this->getSite()->formatResourceLink(Anime::class, $id, $slug),
ExternalResource::ATTRIBUTE_SITE => $this->getSite()->value,
]);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Models/Wiki/BackfillStudiosAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ protected function ensureStudioHasResource(Studio $studio, ResourceSite $site, i
$studioResource = ExternalResource::query()
->where(ExternalResource::ATTRIBUTE_SITE, $site->value)
->where(ExternalResource::ATTRIBUTE_EXTERNAL_ID, $id)
->where(ExternalResource::ATTRIBUTE_LINK, $site->formatStudioResourceLink($id))
->where(ExternalResource::ATTRIBUTE_LINK, $site->formatResourceLink(Studio::class, $id))
->first();

if (! $studioResource instanceof ExternalResource) {
Log::info("Creating studio resource with site '$site->value' and id '$id'");

$studioResource = ExternalResource::query()->create([
ExternalResource::ATTRIBUTE_EXTERNAL_ID => $id,
ExternalResource::ATTRIBUTE_LINK =>$site->formatStudioResourceLink($id),
ExternalResource::ATTRIBUTE_LINK =>$site->formatResourceLink(Studio::class, $id),
ExternalResource::ATTRIBUTE_SITE => $site->value,
]);
}
Expand Down
61 changes: 61 additions & 0 deletions app/Enums/Auth/Role.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

namespace App\Enums\Auth;

/**
* Enum Role.
*/
enum Role: string
{
case ADMIN = 'Admin';

case DEVELOPER = 'Developer';

case ENCODER = 'Encoder';

case PATRON = 'Patron';

case PLAYLIST_USER = 'Playlist User';

case WIKI_EDITOR = 'Wiki Editor';

case WIKI_VIEWER = 'Wiki Viewer';

/**
* Get the color for the role.
*
* @return string|null
*/
public function color(): ?string
{
return match ($this) {
Role::ADMIN => '#1F8B4C',
Role::DEVELOPER => '#FF69B4',
Role::ENCODER => '#FFC107',
Role::PATRON => '#E74C3C',
Role::WIKI_EDITOR => '#2E5A88',
Role::WIKI_VIEWER => '#2596D1',
default => null,
};
}

/**
* Get the priority value for the role.
*
* @return int|null
*/
public function priority(): ?int
{
return match ($this) {
Role::ADMIN => 250000,
Role::DEVELOPER => 125000,
Role::ENCODER => 150000,
Role::PATRON => 50000,
Role::WIKI_EDITOR => 100000,
Role::WIKI_VIEWER => 25000,
default => null,
};
}
}
Loading

0 comments on commit 847189a

Please sign in to comment.