From dae97bfa67f48d4a27addd96b9e511491e99851b Mon Sep 17 00:00:00 2001 From: nicollassilva Date: Tue, 4 Jun 2024 17:29:31 -0300 Subject: [PATCH 01/10] Improving the BBCode render & fixing an issue with article comments --- app/Helpers/functions.php | 23 +++++++++++++++---- .../Article/ArticleCommentController.php | 6 ++++- lang/en.json | 3 ++- lang/pt_BR.json | 3 ++- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/Helpers/functions.php b/app/Helpers/functions.php index c20c38c..f444e37 100644 --- a/app/Helpers/functions.php +++ b/app/Helpers/functions.php @@ -69,6 +69,19 @@ function getSetting(string $key, ?string $defaultValue = null): mixed } } +if(!function_exists('convertTagsToHtml')) { + /** + * Converts tags to HTML. + */ + function convertTagsToHtml(string $tagStart, string $tagEnd, string $htmlTagStart, string $htmlTagEnd, string $content): string + { + $tagStart = preg_quote($tagStart, '/'); + $tagEnd = preg_quote($tagEnd, '/'); + + return preg_replace("/{$tagStart}(.*){$tagEnd}/s", "{$htmlTagStart}$1{$htmlTagEnd}", $content); + }; +} + if(!function_exists('renderBBCodeText')) { /** * Render BBCode text to HTML. @@ -79,11 +92,11 @@ function renderBBCodeText(string $content, bool $reflectLineBreaks = false): str { return Pipeline::send($content) ->through([ - fn (string $content, \Closure $next) => $next(str_replace(['[b]', '[/b]'], ['', ''], $content)), - fn (string $content, \Closure $next) => $next(str_replace(['[i]', '[/i]'], ['', ''], $content)), - fn (string $content, \Closure $next) => $next(str_replace(['[u]', '[/u]'], ['', ''], $content)), - fn (string $content, \Closure $next) => $next(str_replace(['[s]', '[/s]'], ['', ''], $content)), - fn (string $content, \Closure $next) => $next(str_replace(['[h]', '[/h]'], ['', ''], $content)), + fn (string $content, \Closure $next) => $next(convertTagsToHtml('[b]', '[/b]', '', '', $content)), + fn (string $content, \Closure $next) => $next(convertTagsToHtml('[i]', '[/i]', '', '', $content)), + fn (string $content, \Closure $next) => $next(convertTagsToHtml('[u]', '[/u]', '', '', $content)), + fn (string $content, \Closure $next) => $next(convertTagsToHtml('[s]', '[/s]', '', '', $content)), + fn (string $content, \Closure $next) => $next(convertTagsToHtml('[h]', '[/h]', '', '', $content)), ])->then(fn (string $content) => $reflectLineBreaks ? nl2br($content) : $content); } } diff --git a/app/Http/Controllers/Article/ArticleCommentController.php b/app/Http/Controllers/Article/ArticleCommentController.php index f9286fa..c9ffd15 100644 --- a/app/Http/Controllers/Article/ArticleCommentController.php +++ b/app/Http/Controllers/Article/ArticleCommentController.php @@ -14,7 +14,7 @@ class ArticleCommentController extends Controller public function store(string $id, string $slug, Request $request): JsonResponse { $data = $request->validate([ - 'content' => 'required|string|min:5' + 'content' => 'required|string' ]); if (!$article = Article::fromIdAndSlug($id, $slug)->first()) { @@ -27,6 +27,10 @@ public function store(string $id, string $slug, Request $request): JsonResponse return $this->jsonResponse(['message' => __('You are commenting too fast')], 422); } + if(strlen(preg_replace("/\[(\/?).*?\]/", '', $data['content'])) < 5) { + return $this->jsonResponse(['message' => __('Please, type a valid comment.')], 422); + } + $comment = $article->comments()->create([ 'content' => PreventXssService::sanitize($data['content']), 'user_id' => $user->id diff --git a/lang/en.json b/lang/en.json index 67685b9..83ea9a3 100644 --- a/lang/en.json +++ b/lang/en.json @@ -347,5 +347,6 @@ "Your purchase has been delivered! Thank you for supporting us.": "Your purchase has been delivered! Thank you for supporting us.", "registered using your referral link.": "registered using your referral link.", "You cannot edit this user!": "You cannot edit this user", - "You cannot edit users with a higher rank than yours.": "You cannot edit users with a higher rank than yours." + "You cannot edit users with a higher rank than yours.": "You cannot edit users with a higher rank than yours.", + "Please, type a valid comment.": "Please, type a valid comment." } diff --git a/lang/pt_BR.json b/lang/pt_BR.json index 1a841ee..c650541 100644 --- a/lang/pt_BR.json +++ b/lang/pt_BR.json @@ -347,5 +347,6 @@ "Your purchase has been delivered! Thank you for supporting us.": "Sua compra foi entregue! Obrigado por nos apoiar.", "registered using your referral link.": "se registrou usando seu link de indicação.", "You cannot edit this user!": "Você não pode editar este usuário", - "You cannot edit users with a higher rank than yours.": "Você não pode editar usuários com um cargo mais alto que o seu." + "You cannot edit users with a higher rank than yours.": "Você não pode editar usuários com um cargo mais alto que o seu.", + "Please, type a valid comment.": "Por favor, digite um comentário válido." } From f6c2701961b130e17628061a23b40594889f8516 Mon Sep 17 00:00:00 2001 From: nicollassilva Date: Tue, 4 Jun 2024 18:06:42 -0300 Subject: [PATCH 02/10] Fixing to consider the active navigation when navigating sub-navigations --- app/Models/SubNavigation.php | 17 ++++++++++++++ .../components/header/main-nav.blade.php | 22 ++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/app/Models/SubNavigation.php b/app/Models/SubNavigation.php index 7647a77..6f41254 100644 --- a/app/Models/SubNavigation.php +++ b/app/Models/SubNavigation.php @@ -15,6 +15,23 @@ class SubNavigation extends Model public $timestamps = false; + public static function boot(): void + { + parent::boot(); + + static::creating(function (SubNavigation $subNavigation) { + if(!str_starts_with($subNavigation->slug, '/')) { + $subNavigation->slug = "/{$subNavigation->slug}"; + } + }); + + static::updating(function (SubNavigation $subNavigation) { + if(!str_starts_with($subNavigation->slug, '/')) { + $subNavigation->slug = "/{$subNavigation->slug}"; + } + }); + } + public function navigation() { return $this->belongsTo(Navigation::class); diff --git a/resources/views/components/header/main-nav.blade.php b/resources/views/components/header/main-nav.blade.php index 8020059..83bc8d4 100644 --- a/resources/views/components/header/main-nav.blade.php +++ b/resources/views/components/header/main-nav.blade.php @@ -1,7 +1,7 @@ @php($navigations = \App\Models\Navigation::getNavigations())
@@ -16,22 +16,28 @@ class="flex lg:hidden p-4 w-full dark:text-white justify-center items-center cur
From cc99a882a0776d8dadb0dae9fb33b58483ff8b16 Mon Sep 17 00:00:00 2001 From: nicollassilva Date: Tue, 4 Jun 2024 18:35:49 -0300 Subject: [PATCH 05/10] Adding edit button in the active article page to redirect to housekeeping --- .../articles/fragments/active-content.blade.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/resources/views/pages/articles/fragments/active-content.blade.php b/resources/views/pages/articles/fragments/active-content.blade.php index f89c8ad..7055087 100644 --- a/resources/views/pages/articles/fragments/active-content.blade.php +++ b/resources/views/pages/articles/fragments/active-content.blade.php @@ -2,6 +2,20 @@ 'activeArticle' => null ]) +@auth +
+ @can('update', $activeArticle) + + + {{ __('Edit') }} + + @endcan +
+@endauth
Date: Tue, 4 Jun 2024 19:06:25 -0300 Subject: [PATCH 06/10] Adding a way to manage the article comments & adding innapropriate comment system --- .../Resources/Orion/ArticleResource.php | 1 + .../CommentsRelationManager.php | 73 +++++++++++++++++++ app/Models/Article/ArticleComment.php | 5 +- ...riate_column_in_article_comments_table.php | 28 +++++++ lang/en.json | 3 +- lang/pt_BR.json | 3 +- lang/vendor/filament/da/resources.php | 2 + lang/vendor/filament/de/resources.php | 2 + lang/vendor/filament/en/resources.php | 2 + lang/vendor/filament/es/resources.php | 2 + lang/vendor/filament/fi/resources.php | 2 + lang/vendor/filament/fr/resources.php | 2 + lang/vendor/filament/nl/resources.php | 2 + lang/vendor/filament/pt_BR/resources.php | 2 + lang/vendor/filament/tr/resources.php | 2 + .../fragments/article-comments.blade.php | 8 +- 16 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 app/Filament/Resources/Orion/ArticleResource/RelationManagers/CommentsRelationManager.php create mode 100644 database/migrations/2024_06_04_215124_add_innapropriate_column_in_article_comments_table.php diff --git a/app/Filament/Resources/Orion/ArticleResource.php b/app/Filament/Resources/Orion/ArticleResource.php index c68dc72..4400b08 100644 --- a/app/Filament/Resources/Orion/ArticleResource.php +++ b/app/Filament/Resources/Orion/ArticleResource.php @@ -177,6 +177,7 @@ public static function getRelations(): array { return [ RelationManagers\TagsRelationManager::class, + RelationManagers\CommentsRelationManager::class, ]; } diff --git a/app/Filament/Resources/Orion/ArticleResource/RelationManagers/CommentsRelationManager.php b/app/Filament/Resources/Orion/ArticleResource/RelationManagers/CommentsRelationManager.php new file mode 100644 index 0000000..9e577ea --- /dev/null +++ b/app/Filament/Resources/Orion/ArticleResource/RelationManagers/CommentsRelationManager.php @@ -0,0 +1,73 @@ +schema([ + Placeholder::make('content') + ->label(__('filament::resources.inputs.content')) + ->columnSpanFull() + ->extraAttributes(['class' => 'border rounded-lg p-2']) + ->content(fn (ArticleComment $record): HtmlString => new HtmlString(renderBBCodeText($record->content, true))), + ]); + } + + public function table(Table $table): Table + { + return $table + ->recordTitleAttribute('id') + ->columns([ + TextColumn::make('id') + ->toggleable(), + + TextColumn::make('user.username') + ->searchable() + ->label(__('filament::resources.columns.by')), + + ToggleColumn::make('visible') + ->label(__('filament::resources.columns.visible')), + + ToggleColumn::make('fixed') + ->label(__('filament::resources.columns.fixed')), + + ToggleColumn::make('innapropriate') + ->label(__('filament::resources.columns.innapropriate')), + ]) + ->filters([ + // + ]) + ->headerActions([]) + ->actions([ + Tables\Actions\ViewAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + ]), + ]); + } +} diff --git a/app/Models/Article/ArticleComment.php b/app/Models/Article/ArticleComment.php index f8f0c35..18b886b 100644 --- a/app/Models/Article/ArticleComment.php +++ b/app/Models/Article/ArticleComment.php @@ -22,12 +22,13 @@ class ArticleComment extends Model protected $casts = [ 'visible' => 'boolean', - 'fixed' => 'boolean' + 'fixed' => 'boolean', + 'innapropriate' => 'boolean' ]; public function scopeDefaultRelationships(Builder $query): void { - $query->with([ + $query->whereVisible(true)->with([ 'user:id,username,look', 'user.badges' => fn ($query) => $query->where('slot_id', '<>', '0') ]); diff --git a/database/migrations/2024_06_04_215124_add_innapropriate_column_in_article_comments_table.php b/database/migrations/2024_06_04_215124_add_innapropriate_column_in_article_comments_table.php new file mode 100644 index 0000000..22285ed --- /dev/null +++ b/database/migrations/2024_06_04_215124_add_innapropriate_column_in_article_comments_table.php @@ -0,0 +1,28 @@ +boolean('innapropriate')->default(false)->after('fixed'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('article_comments', function (Blueprint $table) { + $table->dropColumn('innapropriate'); + }); + } +}; diff --git a/lang/en.json b/lang/en.json index 83ea9a3..6ee2aab 100644 --- a/lang/en.json +++ b/lang/en.json @@ -348,5 +348,6 @@ "registered using your referral link.": "registered using your referral link.", "You cannot edit this user!": "You cannot edit this user", "You cannot edit users with a higher rank than yours.": "You cannot edit users with a higher rank than yours.", - "Please, type a valid comment.": "Please, type a valid comment." + "Please, type a valid comment.": "Please, type a valid comment.", + "This comment has been marked as innapropriate.": "This comment has been marked as innapropriate." } diff --git a/lang/pt_BR.json b/lang/pt_BR.json index c650541..28fae4c 100644 --- a/lang/pt_BR.json +++ b/lang/pt_BR.json @@ -348,5 +348,6 @@ "registered using your referral link.": "se registrou usando seu link de indicação.", "You cannot edit this user!": "Você não pode editar este usuário", "You cannot edit users with a higher rank than yours.": "Você não pode editar usuários com um cargo mais alto que o seu.", - "Please, type a valid comment.": "Por favor, digite um comentário válido." + "Please, type a valid comment.": "Por favor, digite um comentário válido.", + "This comment has been marked as innapropriate.": "Este comentário foi marcado como inapropriado." } diff --git a/lang/vendor/filament/da/resources.php b/lang/vendor/filament/da/resources.php index c6276b5..9724f54 100644 --- a/lang/vendor/filament/da/resources.php +++ b/lang/vendor/filament/da/resources.php @@ -394,6 +394,7 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'innapropriate' => 'Innapropriate', ], 'options' => [ @@ -692,5 +693,6 @@ 'select_all' => 'Select All', 'deselect_all' => 'Deselect All', 'sent_notifications' => 'Send Notifications', + 'innapropriate' => 'Innapropriate', ] ]; diff --git a/lang/vendor/filament/de/resources.php b/lang/vendor/filament/de/resources.php index 931cdd0..3862f69 100644 --- a/lang/vendor/filament/de/resources.php +++ b/lang/vendor/filament/de/resources.php @@ -394,6 +394,7 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'innapropriate' => 'Innapropriate', ], 'options' => [ @@ -693,6 +694,7 @@ 'select_all' => 'Select All', 'deselect_all' => 'Deselect All', 'send_notifications' => 'Send Notifications', + 'innapropriate' => 'Innapropriate', ] ]; diff --git a/lang/vendor/filament/en/resources.php b/lang/vendor/filament/en/resources.php index 931cdd0..3862f69 100644 --- a/lang/vendor/filament/en/resources.php +++ b/lang/vendor/filament/en/resources.php @@ -394,6 +394,7 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'innapropriate' => 'Innapropriate', ], 'options' => [ @@ -693,6 +694,7 @@ 'select_all' => 'Select All', 'deselect_all' => 'Deselect All', 'send_notifications' => 'Send Notifications', + 'innapropriate' => 'Innapropriate', ] ]; diff --git a/lang/vendor/filament/es/resources.php b/lang/vendor/filament/es/resources.php index d2f01a3..da218c8 100644 --- a/lang/vendor/filament/es/resources.php +++ b/lang/vendor/filament/es/resources.php @@ -394,6 +394,7 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'innapropriate' => 'Innapropriate', ], 'options' => [ @@ -693,5 +694,6 @@ 'select_all' => 'Select All', 'deselect_all' => 'Deselect All', 'send_notifications' => 'Send Notifications', + 'innapropriate' => 'Innapropriate', ] ]; diff --git a/lang/vendor/filament/fi/resources.php b/lang/vendor/filament/fi/resources.php index 3f56cfe..3d2810b 100644 --- a/lang/vendor/filament/fi/resources.php +++ b/lang/vendor/filament/fi/resources.php @@ -394,6 +394,7 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'innapropriate' => 'Innapropriate', ], 'options' => [ @@ -693,5 +694,6 @@ 'select_all' => 'Select All', 'deselect_all' => 'Deselect All', 'send_notifications' => 'Send Notifications', + 'innapropriate' => 'Innapropriate', ] ]; diff --git a/lang/vendor/filament/fr/resources.php b/lang/vendor/filament/fr/resources.php index 6c1fe58..1494993 100644 --- a/lang/vendor/filament/fr/resources.php +++ b/lang/vendor/filament/fr/resources.php @@ -394,6 +394,7 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'innapropriate' => 'Innapropriate', ], 'options' => [ @@ -693,5 +694,6 @@ 'select_all' => 'Select All', 'deselect_all' => 'Deselect All', 'send_notifications' => 'Send Notifications', + 'innapropriate' => 'Innapropriate', ] ]; diff --git a/lang/vendor/filament/nl/resources.php b/lang/vendor/filament/nl/resources.php index 752497f..8d12d1a 100644 --- a/lang/vendor/filament/nl/resources.php +++ b/lang/vendor/filament/nl/resources.php @@ -395,6 +395,7 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'innapropriate' => 'Innapropriate', ], 'options' => [ @@ -694,5 +695,6 @@ 'select_all' => 'Selecteer alles', 'deselect_all' => 'Deselecteer alles', 'send_notifications' => 'Stuur notificaties', + 'innapropriate' => 'Innapropriate', ] ]; diff --git a/lang/vendor/filament/pt_BR/resources.php b/lang/vendor/filament/pt_BR/resources.php index 91dc565..b546f47 100644 --- a/lang/vendor/filament/pt_BR/resources.php +++ b/lang/vendor/filament/pt_BR/resources.php @@ -394,6 +394,7 @@ 'receiver' => 'Destinatário', 'message' => 'Mensagem', 'room' => 'Quarto', + 'innapropriate' => 'Inapropriado', ], 'options' => [ @@ -693,5 +694,6 @@ 'select_all' => 'Selecionar Todos', 'deselect_all' => 'Desmarcar Todos', 'send_notifications' => 'Enviar Notificações', + 'innapropriate' => 'Inapropriado', ] ]; diff --git a/lang/vendor/filament/tr/resources.php b/lang/vendor/filament/tr/resources.php index 72fcee1..14545ac 100644 --- a/lang/vendor/filament/tr/resources.php +++ b/lang/vendor/filament/tr/resources.php @@ -402,6 +402,7 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'innapropriate' => 'Innapropriate', ], 'options' => [ @@ -701,5 +702,6 @@ 'select_all' => 'Select All', 'deselect_all' => 'Deselect All', 'send_notifications' => 'Send Notifications', + 'innapropriate' => 'Innapropriate', ] ]; diff --git a/resources/views/pages/articles/fragments/article-comments.blade.php b/resources/views/pages/articles/fragments/article-comments.blade.php index e3e9824..8524c98 100644 --- a/resources/views/pages/articles/fragments/article-comments.blade.php +++ b/resources/views/pages/articles/fragments/article-comments.blade.php @@ -25,7 +25,13 @@ class="icon small w-[13px] h-[15px] border-none shadow-none rounded-none ifixed"
- {!! $comment->renderedContent !!} + @if($comment->innapropriate) +
+ {{ __('This comment has been marked as innapropriate.') }} +
+ @else + {!! $comment->renderedContent !!} + @endif
From ff8b373e486efa90e9ca0bf4c7667a730f08d200 Mon Sep 17 00:00:00 2001 From: nicollassilva Date: Tue, 4 Jun 2024 19:24:21 -0300 Subject: [PATCH 07/10] Small improvements in the user box component --- .../components/header/user-box.blade.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/resources/views/components/header/user-box.blade.php b/resources/views/components/header/user-box.blade.php index ddb24d2..c0fb16c 100644 --- a/resources/views/components/header/user-box.blade.php +++ b/resources/views/components/header/user-box.blade.php @@ -20,18 +20,26 @@
!request()->routeIs('users.profile.show'), + "bg-white dark:bg-slate-950" => request()->routeIs('users.profile.show') && request()->route('username') === Auth::user()->username + ]) data-tippy data-tippy-content="{{ __('My Profile') }}" - @auth href="{{ route('users.profile.show', Auth::user()->username) }}" @endauth + href="{{ route('users.profile.show', Auth::user()->username) }}" > Profile icon !request()->routeIs('users.settings.index'), + "bg-white dark:bg-slate-950" => request()->routeIs('users.settings.index') + ]) data-tippy data-tippy-content="{{ __('My Settings') }}" - @auth href="{{ route('users.settings.index') }}" @endauth + href="{{ route('users.settings.index') }}" > Settings icon @@ -52,7 +60,11 @@ class="h-full flex-1 flex justify-center items-center hover:bg-gray-50 dark:hove Inbox icon !request()->routeIs('support.questions.index'), + "bg-white dark:bg-slate-950" => request()->routeIs('support.questions.index') + ]) data-tippy data-tippy-content="{{ __('Help & Tricks') }}" href="{{ route('support.questions.index') }}" From b995ffec4c5331206e38c6a0ef2fc4fe388414ee Mon Sep 17 00:00:00 2001 From: nicollassilva Date: Thu, 6 Jun 2024 18:00:02 -0300 Subject: [PATCH 08/10] Feature: Beta Code system --- app/Actions/Fortify/CreateNewUser.php | 29 +++- .../RedirectIfTwoFactorAuthenticatable.php | 23 ++- .../Resources/Orion/BetaCodeResource.php | 100 ++++++++++++ .../Pages/ManageBetaCodes.php | 19 +++ .../Pages/ManageWriteableBoxes.php | 2 +- app/Http/Kernel.php | 1 + .../Middleware/RedirectIfBetaCodeMissing.php | 33 ++++ app/Models/BetaCode.php | 23 +++ app/Models/User.php | 8 +- app/Policies/BetaCodePolicy.php | 151 ++++++++++++++++++ app/Providers/RouteServiceProvider.php | 2 +- config/fortify.php | 2 +- ...4_06_04_223210_create_beta_codes_table.php | 33 ++++ ...35_add_beta_code_column_to_users_table.php | 28 ++++ database/seeders/CmsSettingsSeeder.php | 5 + database/seeders/PermissionRoleSeeder.php | 3 +- lang/en.json | 6 +- lang/pt_BR.json | 6 +- lang/vendor/filament/da/resources.php | 11 ++ lang/vendor/filament/de/resources.php | 11 ++ lang/vendor/filament/en/resources.php | 11 ++ lang/vendor/filament/es/resources.php | 11 ++ lang/vendor/filament/fi/resources.php | 11 ++ lang/vendor/filament/fr/resources.php | 6 + lang/vendor/filament/nl/resources.php | 11 ++ lang/vendor/filament/pt_BR/resources.php | 11 ++ lang/vendor/filament/tr/resources.php | 12 +- .../views/components/forms/login.blade.php | 2 +- resources/views/pages/auth/register.blade.php | 14 +- 29 files changed, 572 insertions(+), 13 deletions(-) create mode 100644 app/Filament/Resources/Orion/BetaCodeResource.php create mode 100644 app/Filament/Resources/Orion/BetaCodeResource/Pages/ManageBetaCodes.php create mode 100644 app/Http/Middleware/RedirectIfBetaCodeMissing.php create mode 100644 app/Models/BetaCode.php create mode 100644 app/Policies/BetaCodePolicy.php create mode 100644 database/migrations/2024_06_04_223210_create_beta_codes_table.php create mode 100644 database/migrations/2024_06_04_223435_add_beta_code_column_to_users_table.php diff --git a/app/Actions/Fortify/CreateNewUser.php b/app/Actions/Fortify/CreateNewUser.php index ef9692d..d513396 100644 --- a/app/Actions/Fortify/CreateNewUser.php +++ b/app/Actions/Fortify/CreateNewUser.php @@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use App\Actions\Compositions\HasAuthAttempt; +use App\Models\BetaCode; use Laravel\Fortify\Contracts\CreatesNewUsers; class CreateNewUser implements CreatesNewUsers @@ -42,10 +43,21 @@ public function create(array $input): User 'ip_current' => $userIp, 'account_day_of_birth' => strtotime($input['birthday']), 'look' => $input['look'] ?? (getSetting($input['gender'] == 'M' ? 'start_male_look' : 'start_female_look')), + 'beta_code' => !! getSetting('beta_period') ? $input['beta_code'] : null, ]), function (User $user) use ($input) { - if(!isset($input['referrer_code'])) return; + if(isset($input['referrer_code'])) { + $this->setReferrer($user, $input['referrer_code']); + } - $this->setReferrer($user, $input['referrer_code']); + if(isset($input['beta_code'])) { + $code = BetaCode::whereCode($input['beta_code'])->whereNull('rescued_at')->first(); + + if(!$code) return; + + $code->update([ + 'rescued_at' => now() + ]); + } }); }); } @@ -92,6 +104,19 @@ private function validateForm(array $input) $validations['cf-turnstile-response'] = ['required', 'string', new TurnstileCheck]; } + if(!! getSetting('beta_period')) { + $validations['beta_code'] = ['required', 'string', function($attribute, $value, $fail) { + if(! $key = BetaCode::whereCode($value)->whereNull('rescued_at')->first()) { + $fail(__('Beta code not found or already used.')); + return; + } + + if($key->valid_at != null && $key->valid_at->lte(now())) { + $fail(__('This beta code has expired.')); + } + }]; + } + try { $gender = config('hotel.cms.register.register_looks')[$input['gender']]; diff --git a/app/Actions/Fortify/RedirectIfTwoFactorAuthenticatable.php b/app/Actions/Fortify/RedirectIfTwoFactorAuthenticatable.php index 7317775..26efcde 100644 --- a/app/Actions/Fortify/RedirectIfTwoFactorAuthenticatable.php +++ b/app/Actions/Fortify/RedirectIfTwoFactorAuthenticatable.php @@ -42,6 +42,10 @@ protected function validateCredentials($request) $this->throwFailedAuthenticationExceptionDuringMaintenance($request); } + if(!! getSetting('beta_period') && $user->rank < getSetting('min_rank_to_bypass_beta_period') && (!$user->betaCode || $user->betaCode->valid_at->lte(now()))) { + $this->throwFailedAuthenticationExceptionDuringBetaPeriod($request); + } + $this->validateCaptcha($request->all()); if (!$user->homeItems()->count()) { @@ -63,7 +67,24 @@ protected function throwFailedAuthenticationExceptionDuringMaintenance($request) $this->limiter->increment($request); throw ValidationException::withMessages([ - Fortify::username() => ['Only staffs can login during maintenance.'], + Fortify::username() => [__('Only staffs can login during maintenance.')], + ]); + } + + /** + * Throw a failed authentication validation exception. + * + * @param \Illuminate\Http\Request $request + * @return void + * + * @throws \Illuminate\Validation\ValidationException + */ + protected function throwFailedAuthenticationExceptionDuringBetaPeriod($request) + { + $this->limiter->increment($request); + + throw ValidationException::withMessages([ + Fortify::username() => [__('You need a valid beta code to login.')], ]); } diff --git a/app/Filament/Resources/Orion/BetaCodeResource.php b/app/Filament/Resources/Orion/BetaCodeResource.php new file mode 100644 index 0000000..c8c8417 --- /dev/null +++ b/app/Filament/Resources/Orion/BetaCodeResource.php @@ -0,0 +1,100 @@ +schema([ + TextInput::make('code') + ->default(\Str::random(60)) + ->label(__('filament::resources.inputs.code')) + ->unique(ignoreRecord: true) + ->required() + ->columnSpan('full') + ->maxLength(64), + + DateTimePicker::make('valid_at') + ->label(__('filament::resources.inputs.valid_at')) + ->columnSpan('full') + ->helperText(__('filament::resources.helpers.beta_code_data_helper')) + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + TextColumn::make('id'), + + TextColumn::make('code') + ->label(__('filament::resources.columns.code')) + ->limit(30) + ->searchable(), + + TextColumn::make('valid_at') + ->date('d/m/Y H:i') + ->label(__('filament::resources.columns.valid_at')), + + TextColumn::make('rescued_at') + ->date('d/m/Y H:i') + ->label(__('filament::resources.columns.rescued_at')), + + TextColumn::make('user.username') + ->searchable() + ->formatStateUsing(fn (?string $state): string => $state ?? '-') + ->label(__('filament::resources.columns.username')), + ]) + ->filters([ + // + ]) + ->actions([ + Tables\Actions\EditAction::make(), + Tables\Actions\ViewAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + ]), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => Pages\ManageBetaCodes::route('/'), + ]; + } +} diff --git a/app/Filament/Resources/Orion/BetaCodeResource/Pages/ManageBetaCodes.php b/app/Filament/Resources/Orion/BetaCodeResource/Pages/ManageBetaCodes.php new file mode 100644 index 0000000..8bc11f0 --- /dev/null +++ b/app/Filament/Resources/Orion/BetaCodeResource/Pages/ManageBetaCodes.php @@ -0,0 +1,19 @@ + \App\Http\Middleware\RedirectIfMaintenance::class, 'findretros.vote' => \App\Http\Middleware\RedirectIfVoteMissing::class, 'vpn.prevent' => \App\Http\Middleware\VerifyVpnAddresses::class, + 'beta.code' => \App\Http\Middleware\RedirectIfBetaCodeMissing::class, ]; } diff --git a/app/Http/Middleware/RedirectIfBetaCodeMissing.php b/app/Http/Middleware/RedirectIfBetaCodeMissing.php new file mode 100644 index 0000000..7702e77 --- /dev/null +++ b/app/Http/Middleware/RedirectIfBetaCodeMissing.php @@ -0,0 +1,33 @@ +rank >= getSetting('min_rank_to_bypass_beta_period')) return $next($request); + + if(!$user->betaCode || $user->betaCode->valid_at->lte(now())) { + Auth::logout(); + + return to_route('index'); + } + + return $next($request); + } +} diff --git a/app/Models/BetaCode.php b/app/Models/BetaCode.php new file mode 100644 index 0000000..8df3a58 --- /dev/null +++ b/app/Models/BetaCode.php @@ -0,0 +1,23 @@ + 'datetime', + 'rescued_at' => 'datetime' + ]; + + public function user() + { + return $this->hasOne(User::class, 'beta_code', 'code'); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 948caa5..6f020b4 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -74,7 +74,8 @@ class User extends Authenticatable implements FilamentUser, HasName, HasAvatar 'team_id', 'provider_id', 'account_day_of_birth', - 'is_hidden' + 'is_hidden', + 'beta_code' ]; /** @@ -200,6 +201,11 @@ public function rooms(): HasMany return $this->hasMany(Room::class, 'owner_id'); } + public function betaCode() + { + return $this->belongsTo(BetaCode::class, 'beta_code', 'code'); + } + public function roles(): HasManyThrough { return $this->hasManyThrough( diff --git a/app/Policies/BetaCodePolicy.php b/app/Policies/BetaCodePolicy.php new file mode 100644 index 0000000..2ebd198 --- /dev/null +++ b/app/Policies/BetaCodePolicy.php @@ -0,0 +1,151 @@ +can('view_any::admin::beta_code'); + } + + /** + * Determine whether the user can view the model. + * + * @param \App\Models\User $user + * @param \App\Models\BetaCode $betaCode + * @return bool + */ + public function view(User $user, BetaCode $betaCode): bool + { + return $user->can('view::admin::beta_code'); + } + + /** + * Determine whether the user can create models. + * + * @param \App\Models\User $user + * @return bool + */ + public function create(User $user): bool + { + return $user->can('create::admin::beta_code'); + } + + /** + * Determine whether the user can update the model. + * + * @param \App\Models\User $user + * @param \App\Models\BetaCode $betaCode + * @return bool + */ + public function update(User $user, BetaCode $betaCode): bool + { + return $user->can('update::admin::beta_code'); + } + + /** + * Determine whether the user can delete the model. + * + * @param \App\Models\User $user + * @param \App\Models\BetaCode $betaCode + * @return bool + */ + public function delete(User $user, BetaCode $betaCode): bool + { + return $user->can('delete::admin::beta_code'); + } + + /** + * Determine whether the user can bulk delete. + * + * @param \App\Models\User $user + * @return bool + */ + public function deleteAny(User $user): bool + { + return $user->can('delete_any::admin::beta_code'); + } + + /** + * Determine whether the user can permanently delete. + * + * @param \App\Models\User $user + * @param \App\Models\BetaCode $betaCode + * @return bool + */ + public function forceDelete(User $user, BetaCode $betaCode): bool + { + return $user->can('force_delete::admin::beta_code'); + } + + /** + * Determine whether the user can permanently bulk delete. + * + * @param \App\Models\User $user + * @return bool + */ + public function forceDeleteAny(User $user): bool + { + return $user->can('force_delete_any::admin::beta_code'); + } + + /** + * Determine whether the user can restore. + * + * @param \App\Models\User $user + * @param \App\Models\BetaCode $betaCode + * @return bool + */ + public function restore(User $user, BetaCode $betaCode): bool + { + return $user->can('restore::admin::beta_code'); + } + + /** + * Determine whether the user can bulk restore. + * + * @param \App\Models\User $user + * @return bool + */ + public function restoreAny(User $user): bool + { + return $user->can('restore_any::admin::beta_code'); + } + + /** + * Determine whether the user can replicate. + * + * @param \App\Models\User $user + * @param \App\Models\BetaCode $betaCode + * @return bool + */ + public function replicate(User $user, BetaCode $betaCode): bool + { + return $user->can('replicate::admin::beta_code'); + } + + /** + * Determine whether the user can reorder. + * + * @param \App\Models\User $user + * @return bool + */ + public function reorder(User $user): bool + { + return $user->can('reorder::admin::beta_code'); + } + +} diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 786093e..9c1f5e8 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -34,7 +34,7 @@ public function boot(): void ->name('api.') ->group(base_path('routes/api.php')); - Route::middleware(['web', 'verify.punishments', 'cms.maintenance']) + Route::middleware(['web', 'verify.punishments', 'cms.maintenance', 'beta.code']) ->group(base_path('routes/web.php')); }); } diff --git a/config/fortify.php b/config/fortify.php index c8d6746..0e21570 100644 --- a/config/fortify.php +++ b/config/fortify.php @@ -89,7 +89,7 @@ | */ - 'middleware' => ['web', 'cms.maintenance', 'verify.punishments'], + 'middleware' => ['web', 'cms.maintenance', 'verify.punishments', 'beta.code'], /* |-------------------------------------------------------------------------- diff --git a/database/migrations/2024_06_04_223210_create_beta_codes_table.php b/database/migrations/2024_06_04_223210_create_beta_codes_table.php new file mode 100644 index 0000000..d8e5b8f --- /dev/null +++ b/database/migrations/2024_06_04_223210_create_beta_codes_table.php @@ -0,0 +1,33 @@ +id(); + + $table->string('code', 64)->unique(); + $table->timestamp('valid_at')->nullable(); + $table->timestamp('rescued_at')->nullable(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('beta_codes'); + } +}; diff --git a/database/migrations/2024_06_04_223435_add_beta_code_column_to_users_table.php b/database/migrations/2024_06_04_223435_add_beta_code_column_to_users_table.php new file mode 100644 index 0000000..3a5eb39 --- /dev/null +++ b/database/migrations/2024_06_04_223435_add_beta_code_column_to_users_table.php @@ -0,0 +1,28 @@ +string('beta_code', 64)->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('beta_code'); + }); + } +}; diff --git a/database/seeders/CmsSettingsSeeder.php b/database/seeders/CmsSettingsSeeder.php index 81b9795..675c749 100644 --- a/database/seeders/CmsSettingsSeeder.php +++ b/database/seeders/CmsSettingsSeeder.php @@ -250,6 +250,11 @@ public function getDefaultSettings(): array 'staff_notification_image', 'https://i.imgur.com/8IcBBTF.gif', 'The staff notification image to show on the CMS' + ], + [ + 'min_rank_to_bypass_beta_period', + '5', + 'The minimum rank to bypass the beta period' ] ]; } diff --git a/database/seeders/PermissionRoleSeeder.php b/database/seeders/PermissionRoleSeeder.php index 0d685f7..5082209 100644 --- a/database/seeders/PermissionRoleSeeder.php +++ b/database/seeders/PermissionRoleSeeder.php @@ -20,7 +20,8 @@ class PermissionRoleSeeder extends Seeder 'shop_category', 'shop_product', 'shop_order', - 'emulator_text' + 'emulator_text', + 'beta_code', ]; private array $strictSuperModeratorPermissions = [ diff --git a/lang/en.json b/lang/en.json index 6ee2aab..8cc2e92 100644 --- a/lang/en.json +++ b/lang/en.json @@ -349,5 +349,9 @@ "You cannot edit this user!": "You cannot edit this user", "You cannot edit users with a higher rank than yours.": "You cannot edit users with a higher rank than yours.", "Please, type a valid comment.": "Please, type a valid comment.", - "This comment has been marked as innapropriate.": "This comment has been marked as innapropriate." + "This comment has been marked as innapropriate.": "This comment has been marked as innapropriate.", + "Beta code not found or already used.": "Beta code not found or already used.", + "This beta code has expired.": "This beta code has expired.", + "Only staffs can login during maintenance.": "Only staffs can login during maintenance.", + "You need a valid beta code to login.": "You need a valid beta code to login." } diff --git a/lang/pt_BR.json b/lang/pt_BR.json index 28fae4c..e64fa39 100644 --- a/lang/pt_BR.json +++ b/lang/pt_BR.json @@ -349,5 +349,9 @@ "You cannot edit this user!": "Você não pode editar este usuário", "You cannot edit users with a higher rank than yours.": "Você não pode editar usuários com um cargo mais alto que o seu.", "Please, type a valid comment.": "Por favor, digite um comentário válido.", - "This comment has been marked as innapropriate.": "Este comentário foi marcado como inapropriado." + "This comment has been marked as innapropriate.": "Este comentário foi marcado como inapropriado.", + "Beta code not found or already used.": "Código beta não encontrado ou já usado.", + "This beta code has expired.": "Esse código beta já expirou.", + "Only staffs can login during maintenance.": "Apenas staffs podem fazer login durante a manutenção.", + "You need a valid beta code to login.": "Você precisa de um código beta válido para fazer login." } diff --git a/lang/vendor/filament/da/resources.php b/lang/vendor/filament/da/resources.php index 9724f54..d126c81 100644 --- a/lang/vendor/filament/da/resources.php +++ b/lang/vendor/filament/da/resources.php @@ -137,6 +137,11 @@ 'label' => 'Room Chatlog', 'plural' => 'Room Chatlogs', ], + 'beta-codes' => [ + 'navigation_label' => 'Manage Beta Codes', + 'label' => 'Code', + 'plural' => 'Codes', + ], // Relations 'settings' => [ @@ -212,6 +217,7 @@ 'currency_item_data_helper' => 'Enter the currency name below. Can be one of: diamonds, duckets, credits or points', 'rank_item_data_helper' => 'Enter the rank ID below.', 'empty_item_data_helper' => 'Select an item type to view the necessary information.', + 'beta_code_data_helper' => "Leave it empty if you don't want to limit the code to specific data.", ], 'tabs' => [ @@ -331,6 +337,8 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'code' => 'Code', + 'valid_at' => 'Valid At' ], 'columns' => [ @@ -395,6 +403,9 @@ 'message' => 'Message', 'room' => 'Room', 'innapropriate' => 'Innapropriate', + 'code' => 'Code', + 'valid_at' => 'Valid At', + 'rescued_at' => 'Rescued At', ], 'options' => [ diff --git a/lang/vendor/filament/de/resources.php b/lang/vendor/filament/de/resources.php index 3862f69..1adaebf 100644 --- a/lang/vendor/filament/de/resources.php +++ b/lang/vendor/filament/de/resources.php @@ -137,6 +137,11 @@ 'label' => 'Room Chatlog', 'plural' => 'Room Chatlogs', ], + 'beta-codes' => [ + 'navigation_label' => 'Manage Beta Codes', + 'label' => 'Code', + 'plural' => 'Codes', + ], // Relations 'settings' => [ @@ -212,6 +217,7 @@ 'currency_item_data_helper' => 'Enter the currency name below. Can be one of: credits, duckets, diamonds or points', 'rank_item_data_helper' => 'Enter the rank ID below.', 'empty_item_data_helper' => 'Select an item type to view the necessary information.', + 'beta_code_data_helper' => "Leave it empty if you don't want to limit the code to specific data.", ], 'tabs' => [ @@ -331,6 +337,8 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'code' => 'Code', + 'valid_at' => 'Valid At' ], 'columns' => [ @@ -395,6 +403,9 @@ 'message' => 'Message', 'room' => 'Room', 'innapropriate' => 'Innapropriate', + 'code' => 'Code', + 'valid_at' => 'Valid At', + 'rescued_at' => 'Rescued At', ], 'options' => [ diff --git a/lang/vendor/filament/en/resources.php b/lang/vendor/filament/en/resources.php index 3862f69..c917723 100644 --- a/lang/vendor/filament/en/resources.php +++ b/lang/vendor/filament/en/resources.php @@ -137,6 +137,11 @@ 'label' => 'Room Chatlog', 'plural' => 'Room Chatlogs', ], + 'beta-codes' => [ + 'navigation_label' => 'Manage Beta Codes', + 'label' => 'Code', + 'plural' => 'Codes', + ], // Relations 'settings' => [ @@ -212,6 +217,7 @@ 'currency_item_data_helper' => 'Enter the currency name below. Can be one of: credits, duckets, diamonds or points', 'rank_item_data_helper' => 'Enter the rank ID below.', 'empty_item_data_helper' => 'Select an item type to view the necessary information.', + 'beta_code_data_helper' => "Leave it empty if you don't want to limit the code to specific data.", ], 'tabs' => [ @@ -331,6 +337,8 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'code' => 'Code', + 'valid_at' => 'Valid At', ], 'columns' => [ @@ -395,6 +403,9 @@ 'message' => 'Message', 'room' => 'Room', 'innapropriate' => 'Innapropriate', + 'code' => 'Code', + 'valid_at' => 'Valid At', + 'rescued_at' => 'Rescued At', ], 'options' => [ diff --git a/lang/vendor/filament/es/resources.php b/lang/vendor/filament/es/resources.php index da218c8..baf035f 100644 --- a/lang/vendor/filament/es/resources.php +++ b/lang/vendor/filament/es/resources.php @@ -137,6 +137,11 @@ 'label' => 'Room Chatlog', 'plural' => 'Room Chatlogs', ], + 'beta-codes' => [ + 'navigation_label' => 'Manage Beta Codes', + 'label' => 'Code', + 'plural' => 'Codes', + ], // Relations 'settings' => [ @@ -212,6 +217,7 @@ 'currency_item_data_helper' => 'Enter the currency name below. Can be one of: credits, duckets, diamonds or points', 'rank_item_data_helper' => 'Enter the rank ID below.', 'empty_item_data_helper' => 'Select an item type to view the necessary information.', + 'beta_code_data_helper' => "Leave it empty if you don't want to limit the code to specific data.", ], 'tabs' => [ @@ -331,6 +337,8 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'code' => 'Code', + 'valid_at' => 'Valid At' ], 'columns' => [ @@ -395,6 +403,9 @@ 'message' => 'Message', 'room' => 'Room', 'innapropriate' => 'Innapropriate', + 'code' => 'Code', + 'valid_at' => 'Valid At', + 'rescued_at' => 'Rescued At', ], 'options' => [ diff --git a/lang/vendor/filament/fi/resources.php b/lang/vendor/filament/fi/resources.php index 3d2810b..f448a06 100644 --- a/lang/vendor/filament/fi/resources.php +++ b/lang/vendor/filament/fi/resources.php @@ -137,6 +137,11 @@ 'label' => 'Room Chatlog', 'plural' => 'Room Chatlogs', ], + 'beta-codes' => [ + 'navigation_label' => 'Manage Beta Codes', + 'label' => 'Code', + 'plural' => 'Codes', + ], // Relations 'settings' => [ @@ -212,6 +217,7 @@ 'currency_item_data_helper' => 'Enter the currency name below. Can be one of: credits, duckets, diamonds or points', 'rank_item_data_helper' => 'Enter the rank ID below.', 'empty_item_data_helper' => 'Select an item type to view the necessary information.', + 'beta_code_data_helper' => "Leave it empty if you don't want to limit the code to specific data.", ], 'tabs' => [ @@ -331,6 +337,8 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'code' => 'Code', + 'valid_at' => 'Valid At' ], 'columns' => [ @@ -395,6 +403,9 @@ 'message' => 'Message', 'room' => 'Room', 'innapropriate' => 'Innapropriate', + 'code' => 'Code', + 'valid_at' => 'Valid At', + 'rescued_at' => 'Rescued At', ], 'options' => [ diff --git a/lang/vendor/filament/fr/resources.php b/lang/vendor/filament/fr/resources.php index 1494993..e1df67c 100644 --- a/lang/vendor/filament/fr/resources.php +++ b/lang/vendor/filament/fr/resources.php @@ -212,6 +212,7 @@ 'currency_item_data_helper' => 'Enter the currency name below. Can be one of: credits, duckets, diamonds or points', 'rank_item_data_helper' => 'Enter the rank ID below.', 'empty_item_data_helper' => 'Select an item type to view the necessary information.', + 'beta_code_data_helper' => "Leave it empty if you don't want to limit the code to specific data.", ], 'tabs' => [ @@ -331,6 +332,8 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'code' => 'Code', + 'valid_at' => 'Valid At', ], 'columns' => [ @@ -395,6 +398,9 @@ 'message' => 'Message', 'room' => 'Room', 'innapropriate' => 'Innapropriate', + 'code' => 'Code', + 'valid_at' => 'Valid At', + 'rescued_at' => 'Rescued At', ], 'options' => [ diff --git a/lang/vendor/filament/nl/resources.php b/lang/vendor/filament/nl/resources.php index 8d12d1a..45d3bf4 100644 --- a/lang/vendor/filament/nl/resources.php +++ b/lang/vendor/filament/nl/resources.php @@ -137,6 +137,11 @@ 'label' => 'Room Chatlog', 'plural' => 'Room Chatlogs', ], + 'beta-codes' => [ + 'navigation_label' => 'Manage Beta Codes', + 'label' => 'Code', + 'plural' => 'Codes', + ], // Relations 'settings' => [ @@ -213,6 +218,7 @@ 'currency_item_data_helper' => 'Voer hieronder de valutanaam in. Kan een van de volgende zijn: credits, duckets, diamanten of punten.', 'rank_item_data_helper' => 'Voer de Rank ID in.', 'empty_item_data_helper' => 'Selecteer een itemtype om de benodigde informatie te bekijken.', + 'beta_code_data_helper' => "Leave it empty if you don't want to limit the code to specific data.", ], 'tabs' => [ @@ -332,6 +338,8 @@ 'receiver' => 'Receiver', 'message' => 'Message', 'room' => 'Room', + 'code' => 'Code', + 'valid_at' => 'Valid At' ], 'columns' => [ @@ -396,6 +404,9 @@ 'message' => 'Message', 'room' => 'Room', 'innapropriate' => 'Innapropriate', + 'code' => 'Code', + 'valid_at' => 'Valid At', + 'rescued_at' => 'Rescued At', ], 'options' => [ diff --git a/lang/vendor/filament/pt_BR/resources.php b/lang/vendor/filament/pt_BR/resources.php index b546f47..7d5d3c4 100644 --- a/lang/vendor/filament/pt_BR/resources.php +++ b/lang/vendor/filament/pt_BR/resources.php @@ -137,6 +137,11 @@ 'label' => 'Mensagem', 'plural' => 'Mensagens', ], + 'beta-codes' => [ + 'navigation_label' => 'Gerenciar Códigos Beta', + 'label' => 'Código', + 'plural' => 'Códigos', + ], // Relations 'settings' => [ @@ -212,6 +217,7 @@ 'currency_item_data_helper' => 'Digite abaixo o nome da moeda. Exemplo: credits, duckets, diamonds ou points.', 'rank_item_data_helper' => 'Digite abaixo o ID do rank.', 'empty_item_data_helper' => 'Selecione um tipo de item para ver as informações necessárias.', + 'beta_code_data_helper' => 'Deixe vazio caso não queira limitar o código até uma data específica.', ], 'tabs' => [ @@ -331,6 +337,8 @@ 'receiver' => 'Destinatário', 'message' => 'Mensagem', 'room' => 'Quarto', + 'code' => 'Código', + 'valid_at' => 'Válido até', ], 'columns' => [ @@ -395,6 +403,9 @@ 'message' => 'Mensagem', 'room' => 'Quarto', 'innapropriate' => 'Inapropriado', + 'code' => 'Código', + 'valid_at' => 'Válido até', + 'rescued_at' => 'Resgatado em', ], 'options' => [ diff --git a/lang/vendor/filament/tr/resources.php b/lang/vendor/filament/tr/resources.php index 14545ac..ded8017 100644 --- a/lang/vendor/filament/tr/resources.php +++ b/lang/vendor/filament/tr/resources.php @@ -137,6 +137,11 @@ 'label' => 'Room Chatlog', 'plural' => 'Room Chatlogs', ], + 'beta-codes' => [ + 'navigation_label' => 'Manage Beta Codes', + 'label' => 'Code', + 'plural' => 'Codes', + ], // Relations 'settings' => [ @@ -212,7 +217,7 @@ 'currency_item_data_helper' => 'Para birimi adını aşağıya girin. Şunlardan biri olabilir: credits, duckets, diamonds or points', 'rank_item_data_helper' => 'Rütbe adını aşağıya girin.', 'empty_item_data_helper' => ' Gerekli bilgileri görüntülemek için bir eşya türü seçin.', - + 'beta_code_data_helper' => "Leave it empty if you don't want to limit the code to specific data.", ], 'tabs' => [ @@ -339,6 +344,8 @@ 'sender' => 'Sender', 'receiver' => 'Receiver', 'room' => 'Room', + 'code' => 'Code', + 'valid_at' => 'Valid At' ], 'columns' => [ @@ -403,6 +410,9 @@ 'message' => 'Message', 'room' => 'Room', 'innapropriate' => 'Innapropriate', + 'code' => 'Code', + 'valid_at' => 'Valid At', + 'rescued_at' => 'Rescued At', ], 'options' => [ diff --git a/resources/views/components/forms/login.blade.php b/resources/views/components/forms/login.blade.php index e06a821..0c4ed18 100644 --- a/resources/views/components/forms/login.blade.php +++ b/resources/views/components/forms/login.blade.php @@ -69,7 +69,7 @@ class="dark:bg-blue-600 bg-blue-500 border-blue-700 hover:bg-blue-400 dark:hover
- @if (!$removeSocialButtons) + @if (!$removeSocialButtons && !getSetting('beta_period'))
{{ __('or join with') }} diff --git a/resources/views/pages/auth/register.blade.php b/resources/views/pages/auth/register.blade.php index f53728a..8315481 100644 --- a/resources/views/pages/auth/register.blade.php +++ b/resources/views/pages/auth/register.blade.php @@ -151,6 +151,19 @@ class="w-[84px] h-[130px] border-2 cursor-pointer bg-slate-100 dark:bg-slate-800
+ @if(!! getSetting('beta_period')) +
+ +
+ @endif +
@includeWhen(config('hotel.recaptcha.enabled'), 'components.ui.recaptcha') @includeWhen(config('hotel.turnstile.enabled'), 'components.ui.turnstile') @@ -167,7 +180,6 @@ class="dark:bg-blue-600 bg-blue-500 border-blue-700 hover:bg-blue-400 dark:hover
- @endsection From c56edee59651024ad6dcc6d9d517b32d574dd632 Mon Sep 17 00:00:00 2001 From: nicollassilva Date: Thu, 6 Jun 2024 18:01:49 -0300 Subject: [PATCH 09/10] Fixing default sort in the BetaCodeResource --- app/Filament/Resources/Orion/BetaCodeResource.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Filament/Resources/Orion/BetaCodeResource.php b/app/Filament/Resources/Orion/BetaCodeResource.php index c8c8417..e546dd7 100644 --- a/app/Filament/Resources/Orion/BetaCodeResource.php +++ b/app/Filament/Resources/Orion/BetaCodeResource.php @@ -49,6 +49,7 @@ public static function form(Form $form): Form public static function table(Table $table): Table { return $table + ->defaultSort('id', 'desc') ->columns([ TextColumn::make('id'), From 7ff3d0b8213ccda5ecf9f1d17fb5bfada7c5bfc6 Mon Sep 17 00:00:00 2001 From: nicollassilva Date: Thu, 6 Jun 2024 18:11:07 -0300 Subject: [PATCH 10/10] Fixing beta code input appearence --- .../views/components/forms/register.blade.php | 14 +++++++++++ resources/views/pages/auth/register.blade.php | 25 +++++++++---------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/resources/views/components/forms/register.blade.php b/resources/views/components/forms/register.blade.php index a677ec6..3f5112f 100644 --- a/resources/views/components/forms/register.blade.php +++ b/resources/views/components/forms/register.blade.php @@ -8,6 +8,20 @@ {{ __('You are being invited by') }} + + @if(!! getSetting('beta_period')) +
+ +
+ @endif +
+ @if(!! getSetting('beta_period')) +
+ +
+ @endif
- -
- @endif -
@includeWhen(config('hotel.recaptcha.enabled'), 'components.ui.recaptcha') @includeWhen(config('hotel.turnstile.enabled'), 'components.ui.turnstile')