From b9b2471336cf83f40b7699334d2668ae5daad21d Mon Sep 17 00:00:00 2001 From: KaniRobinson Date: Sat, 13 Jul 2024 17:32:56 +0100 Subject: [PATCH] Laravel 11 Structure Cleanup --- composer.json | 3 +- config/installation.php | 7 ++-- database/factories/.gitkeep | 0 database/factories/ModelFactory.php | 19 --------- ...create_website_installation_table.php.stub | 20 ---------- resources/lang/gb.json | 24 +++++++++++ .../components/layouts/default.blade.php | 23 ----------- resources/views/index.blade.php | 8 ++-- resources/views/step.blade.php | 21 ++++++---- .../Controllers/InstallationController.php | 10 ++--- src/InstallationServiceProvider.php | 40 ++++++++++++------- 11 files changed, 76 insertions(+), 99 deletions(-) create mode 100644 database/factories/.gitkeep delete mode 100644 database/factories/ModelFactory.php delete mode 100644 database/migrations/create_website_installation_table.php.stub create mode 100644 resources/lang/gb.json delete mode 100644 resources/views/components/layouts/default.blade.php diff --git a/composer.json b/composer.json index e80e913..b6e4688 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,7 @@ "license": "MIT", "authors": [], "require": { - "php": "^8.1", - "spatie/laravel-package-tools": "^1.16", + "php": "^8.2", "illuminate/contracts": "^10.0||^11.0" }, "require-dev": { diff --git a/config/installation.php b/config/installation.php index 348b4e9..16c99b7 100644 --- a/config/installation.php +++ b/config/installation.php @@ -2,10 +2,9 @@ return [ 'settings' => [ - 1 => ['theme', 'hotel_name', 'rcon_ip', 'rcon_port', 'avatar_imager', 'discord_invitation_link', 'discord_widget_id'], + 1 => ['theme', 'hotel_name', 'rcon_ip', 'rcon_port', 'discord_invitation_link', 'discord_widget_id'], 2 => ['start_motto', 'start_credits', 'start_duckets', 'start_diamonds', 'start_points', 'start_look', 'max_accounts_per_ip'], - 3 => ['referrals_needed', 'referral_reward_amount', 'min_staff_rank', 'maintenance_message', 'requires_beta_code', 'disable_registration', 'cms_color_mode'], - 4 => ['give_hc_on_register', 'hc_on_register_duration', 'max_comment_per_article', 'website_wordfilter_enabled', 'vpn_block_enabled', 'ipdata_api_key', 'housekeeping_url'], - 5 => [], + 3 => ['min_staff_rank', 'disable_registration', 'cms_color_mode', 'give_hc_on_register', 'hc_on_register_duration'], + 4 => [], ], ]; diff --git a/database/factories/.gitkeep b/database/factories/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php deleted file mode 100644 index b5a1028..0000000 --- a/database/factories/ModelFactory.php +++ /dev/null @@ -1,19 +0,0 @@ -id(); - $table->integer('step')->default(0); - $table->string('installation_key'); - $table->string('user_ip')->nullable(); - $table->boolean('completed')->default(false); - $table->timestamps(); - }); - } -}; diff --git a/resources/lang/gb.json b/resources/lang/gb.json new file mode 100644 index 0000000..e6383b0 --- /dev/null +++ b/resources/lang/gb.json @@ -0,0 +1,24 @@ +{ + "title": "Welcome to Atom CMS", + "subtitle": "We are delighted of having you trying Atom CMS", + "installation_key": "Installation Key", + "installation_key.start_button": "Start the setup", + "installation_key.placeholder": "Enter your installation key", + "installation_key.message_1": "Hello there! We are truly grateful that you have chosen Atom CMS for your hotel.", + "installation_key.message_2": "Atom CMS is built with the community in mind, meaning we highly value community input, rather than only bringing our own ideas & vision to the CMS we try our very best to implement suggestions made by our beloved community. We want everyone to be able to contribute or customise Atom CMS to their needs without having a bachelor in programming.", + "installation_key.message_3": "Atom CMS sole purpose is to empower hotel owners like you. We want you to be able to run your hotel with ease. Our user-friendly interface, robust features, and helpful community are here to ensure that your experience with Atom CMS is nothing short of exceptional!", + "installation_key.message_4": "As you dive into Atom CMS, we encourage you to explore the extensive range of features we have curated to help you bring your vision to life. From customizable templates to seamless integrations with clients like Nitro, we will have you set up in no time.", + "installation_key.message_5": "To get started, we recommend checking out our comprehensive documentation, which will guide you through the initial setup and help you make the most of your Atom CMS experience.", + "installation_key.message_6": "And remember, please join our Discord. If you have any questions or need assistance, please do not hesitate to reach out. We are here to help you every step of the way.", + "installation_key.message_7": "Once again, thank you for choosing Atom CMS, and we cannot wait to see the incredible project you will create.", + "installation_key.message_8": "With everything being said we just want to wish you a warm welcome to the Atom CMS family!", + "installation_key.message_9": "To avoid any third-party party abuse, please provide the installation code, which can be found in your database inside the \"website_installation\" table under the column \"installation_key\".", + "step.complete_button": "Take me to :hotel", + "step.restart_button": "Restart installation", + "step.continue_button": "Continue to Step :step", + "step.message_1": "Congratulations on successfully completing the Atom CMS setup! You have now taken the first steps towards an exciting new journey. With Atom CMS, you can effortlessly manage various aspect of your hotel, while giving your new visitors an easy gateway into a world of joy.", + "step.message_2": "You can at any time change the settings you went through. All it takes is for you to hop into your database and find the \"website_settings\" table and then tweak the settings you wish. Who knows... As you explore the features and functionalities of Atom CMS, you might discover features that will improve you and your users experience & helping you achieve your online goals!", + "step.message_3": "We also have written a throughout documentation, explaining tons of things regarding managing Atom CMS & other aspect of your hotel. You can visit our comprehensive documentation right here. Our goal is to keep expanding our coverage, so keep checking it from time to time.", + "step.message_4": "Lastly, we just want to show our gratitude by letting your know how delighted we are to be a part of your journey and we hope you will gain some amazing memories. So, here is to your new hotel, the boundless creativity it will inspire, and the endless possibilities that lie ahead.", + "step.message_5": "Once again, congratulations and best of wishes for you & your hotel!" +} \ No newline at end of file diff --git a/resources/views/components/layouts/default.blade.php b/resources/views/components/layouts/default.blade.php deleted file mode 100644 index 4dce7d8..0000000 --- a/resources/views/components/layouts/default.blade.php +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - Atom Installation - - - - @vite(['resources/css/app.css'], 'build') - @stack('scripts') - - - -
- {{ $slot }} -
- - - diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index aa49e15..85d833e 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -1,4 +1,4 @@ - +

{{ __('installation_key.message_1') }}

@@ -8,8 +8,8 @@

{!! __('installation_key.message_5', ['documentation_link' => 'https://retros.guide']) !!}

{!! __('installation_key.message_6', ['discord_link' => 'https://discord.gg/rX3aShUHdg']) !!}

{{ __('installation_key.message_7') }}

-

{{ __('installation_key.message_8') }}

-

{{ __('installation_key.message_9') }}

+

{{ __('installation_key.message_8') }}

+

{{ __('installation_key.message_9') }}

@csrf @@ -24,4 +24,4 @@
-
+ diff --git a/resources/views/step.blade.php b/resources/views/step.blade.php index 0892ebc..f72a342 100644 --- a/resources/views/step.blade.php +++ b/resources/views/step.blade.php @@ -1,4 +1,4 @@ - +
@@ -6,17 +6,24 @@ @csrf - @forelse ($settings as $setting) - + @forelse ($fields as $field) + @empty

{{ __('step.message_1') }}

{{ __('step.message_2') }}

{!! __('step.message_3', ['documentation_link' => 'https://retros.guide']) !!}

{{ __('step.message_4') }}

-

{{ __('step.message_5') }}

+

{{ __('step.message_5') }}

@endforelse @@ -44,4 +51,4 @@ class="w-full mt-3">
-
+ diff --git a/src/Http/Controllers/InstallationController.php b/src/Http/Controllers/InstallationController.php index b2dbeac..01a6d6b 100644 --- a/src/Http/Controllers/InstallationController.php +++ b/src/Http/Controllers/InstallationController.php @@ -40,14 +40,14 @@ public function show(int $installation): View { $name = WebsiteSetting::firstWhere('key', 'hotel_name'); + $step = $installation; + + $fields = Arr::get(config('installation.settings', []), $installation, []); + $settings = WebsiteSetting::whereIn('key', Arr::get(config('installation.settings', []), $installation, [])) ->get(); - return view('installation::step', [ - 'name' => $name, - 'step' => $installation, - 'settings' => $settings, - ]); + return view('installation::step', compact('name', 'step', 'fields', 'settings')); } /** diff --git a/src/InstallationServiceProvider.php b/src/InstallationServiceProvider.php index 9deef52..3c125ca 100644 --- a/src/InstallationServiceProvider.php +++ b/src/InstallationServiceProvider.php @@ -2,27 +2,37 @@ namespace Atom\Installation; -use Spatie\LaravelPackageTools\Package; -use Spatie\LaravelPackageTools\PackageServiceProvider; +use Illuminate\Support\ServiceProvider; -class InstallationServiceProvider extends PackageServiceProvider +class InstallationServiceProvider extends ServiceProvider { /** - * Configure the package. + * Register any application services. + * + * @return void */ - public function configurePackage(Package $package): void + public function register() { - $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); + $this->mergeConfigFrom( + path: __DIR__.'/../config/installation.php', + key: 'installation' + ); - $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'installation'); + $this->loadMigrationsFrom( + paths: __DIR__.'/../database/migrations' + ); - $package - ->name('installation') - ->hasConfigFile() - ->hasRoute('web') - ->hasViews() - ->hasTranslations() - ->hasMigrations(['create_website_installation_table']) - ->runsMigrations(); + $this->loadJsonTranslationsFrom( + path: __DIR__.'/../resources/lang' + ); + + $this->loadViewsFrom( + path: __DIR__.'/../resources/views', + namespace: 'installation', + ); + + $this->loadRoutesFrom( + path: __DIR__.'/../routes/web.php' + ); } }