From 38db0a6ee0a028397c91c7842bcac6245dff37c6 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Tue, 9 May 2023 18:04:11 +0200 Subject: [PATCH 1/4] Fix Notifications --- app/Models/User.php | 5 +++-- app/Notifications/ReferralNotification.php | 13 +++++++++++-- app/Notifications/WelcomeMessage.php | 5 ++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index da4a3a7f..6d14f585 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -106,8 +106,8 @@ class User extends Authenticatable implements MustVerifyEmail { parent::boot(); - static::created(function (User $user, GeneralSettings $general_settings, UserSettings $user_settings) { - $user->notify(new WelcomeMessage($user, $general_settings, $user_settings)); + static::created(function (User $user) { + $user->notify(new WelcomeMessage($user)); }); static::deleting(function (User $user) { @@ -276,6 +276,7 @@ class User extends Authenticatable implements MustVerifyEmail public function verifyEmail() { + $this->forceFill([ 'email_verified_at' => now(), ])->save(); diff --git a/app/Notifications/ReferralNotification.php b/app/Notifications/ReferralNotification.php index a1eaff0c..f8acbcf5 100644 --- a/app/Notifications/ReferralNotification.php +++ b/app/Notifications/ReferralNotification.php @@ -19,6 +19,10 @@ class ReferralNotification extends Notification private $ref_user; + private $reward; + + private $credits_display_name; + /** * Create a new notification instance. * @@ -26,6 +30,11 @@ class ReferralNotification extends Notification */ public function __construct(int $user, int $ref_user) { + $general_settings= new GeneralSettings(); + $referral_settings = new ReferralSettings(); + + $this->credits_display_name = $general_settings->credits_display_name; + $this->reward = $referral_settings->reward; $this->user = User::findOrFail($user); $this->ref_user = User::findOrFail($ref_user); } @@ -47,12 +56,12 @@ class ReferralNotification extends Notification * @param mixed $notifiable * @return array */ - public function toArray($notifiable, GeneralSettings $general_settings, ReferralSettings $referral_settings) + public function toArray($notifiable) { return [ 'title' => __('Someone registered using your Code!'), 'content' => ' -

You received '. $referral_settings->reward . ' ' . $general_settings->credits_display_name . '

+

You received '. $this->reward . ' ' . $this->credits_display_name . '

because ' . $this->ref_user->name . ' registered with your Referral-Code!

Thank you very much for supporting us!.

'.config('app.name', 'Laravel').'

diff --git a/app/Notifications/WelcomeMessage.php b/app/Notifications/WelcomeMessage.php index ac33e1c1..7bef9f84 100644 --- a/app/Notifications/WelcomeMessage.php +++ b/app/Notifications/WelcomeMessage.php @@ -33,8 +33,11 @@ class WelcomeMessage extends Notification implements ShouldQueue * * @param User $user */ - public function __construct(User $user, GeneralSettings $general_settings, UserSettings $user_settings) + public function __construct(User $user) { + $general_settings= new GeneralSettings(); + $user_settings = new UserSettings(); + $this->user = $user; $this->credits_display_name = $general_settings->credits_display_name; $this->credits_reward_after_verify_discord = $user_settings->credits_reward_after_verify_discord; From 5cff1e54615f1e88870f7a7cbcba4a59e2614f8b Mon Sep 17 00:00:00 2001 From: 1day2die Date: Thu, 11 May 2023 09:32:13 +0200 Subject: [PATCH 2/4] Re-Implement Image uploading --- .../Controllers/Admin/SettingsController.php | 21 ++++++++ routes/web.php | 7 ++- .../views/admin/settings/index.blade.php | 54 +++++++++++++++++++ 3 files changed, 78 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Admin/SettingsController.php b/app/Http/Controllers/Admin/SettingsController.php index 7d1657f1..47cc4207 100644 --- a/app/Http/Controllers/Admin/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsController.php @@ -138,4 +138,25 @@ class SettingsController extends Controller return Redirect::to('admin/settings' . '#' . $category)->with('success', 'Settings updated successfully.'); } + + public function updateIcons(Request $request) + { + $request->validate([ + 'icon' => 'nullable|max:10000|mimes:jpg,png,jpeg', + 'logo' => 'nullable|max:10000|mimes:jpg,png,jpeg', + 'favicon' => 'nullable|max:10000|mimes:ico', + ]); + + if ($request->hasFile('icon')) { + $request->file('icon')->storeAs('public', 'icon.png'); + } + if ($request->hasFile('logo')) { + $request->file('logo')->storeAs('public', 'logo.png'); + } + if ($request->hasFile('favicon')) { + $request->file('favicon')->storeAs('public', 'favicon.ico'); + } + + return Redirect::to('admin/settings')->with('success', 'Icons updated successfully.'); + } } diff --git a/routes/web.php b/routes/web.php index 425c5613..5e09c048 100644 --- a/routes/web.php +++ b/routes/web.php @@ -169,13 +169,12 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () { Route::get('payments', [PaymentController::class, 'index'])->name('payments.index'); //settings - Route::get('settings/datatable', [SettingsController::class, 'datatable'])->name('settings.datatable'); - Route::patch('settings/updatevalue', [SettingsController::class, 'updatevalue'])->name('settings.updatevalue'); - Route::get('settings/checkPteroClientkey', [System::class, 'checkPteroClientkey'])->name('settings.checkPteroClientkey'); - Route::redirect('settings#system', 'system')->name('settings.system'); + Route::get('settings', [SettingsController::class, 'index'])->name('settings.index'); Route::post('settings', [SettingsController::class, 'update'])->name('settings.update'); + Route::post('settings/icons', [SettingsController::class, 'updateIcons'])->name('settings.updateIcons'); + //invoices Route::get('invoices/download-invoices', [InvoiceController::class, 'downloadAllInvoices'])->name('invoices.downloadAllInvoices'); diff --git a/themes/default/views/admin/settings/index.blade.php b/themes/default/views/admin/settings/index.blade.php index 28615dbe..f3438dd2 100644 --- a/themes/default/views/admin/settings/index.blade.php +++ b/themes/default/views/admin/settings/index.blade.php @@ -44,6 +44,17 @@ @@ -85,32 +121,41 @@ @csrf @method('POST')
-
- {{__("FavIcon")}} -
- -
- -
-
- {{__("Icon")}} - ... + {{__("FavIcon")}}
- +
+ +
+ {{__("Icon")}} + ... +
+ +
+
{{__("Login-page Logo")}} - ... + ...
-
@@ -121,104 +166,110 @@ @foreach ($settings as $category => $options) @canany(["settings.".strtolower($category).".read","settings.".strtolower($category).".write"]) -
+
-
- @csrf - @method('POST') - - + + @csrf + @method('POST') + + - @foreach ($options as $key => $value) - @if ($key == 'category_icon' || $key == 'settings_class') - @continue - @endif -
-
- -
+ @foreach ($options as $key => $value) + @if ($key == 'category_icon' || $key == 'settings_class') + @continue + @endif +
+
+ +
-
-
- @if ($value['description']) - - @else - - @endif +
+
+ @if ($value['description']) + + @else + + @endif -
- @switch($value) - @case($value['type'] == 'string') - - @break +
+ @switch($value) + @case($value['type'] == 'string') + + @break - @case($value['type'] == 'boolean') - - @break + @case($value['type'] == 'boolean') + + @break - @case($value['type'] == 'number') - - @break + @case($value['type'] == 'number') + + @break - @case($value['type'] == 'select') - - @foreach ($value['options'] as $option=>$display) - - @endforeach - - @break + @foreach ($value['options'] as $option=>$display) + + @endforeach + + @break - @case($value['type'] == 'multiselect') - - @break + @case($value['type'] == 'multiselect') + + @break - @case($value['type'] == 'textarea') - - @break + @case($value['type'] == 'textarea') + + @break - @default - @endswitch - @error($key) + @default + @endswitch + @error($key)
{{ $message }}
- @enderror + @enderror +
+ +
-
-
-
- @endforeach + @endforeach - -
-
- - +
+
+ + +
-
- -
+ +
@endcanany @endforeach @@ -261,9 +314,8 @@
-
- + @@ -277,7 +329,7 @@ $('.nav-item a[href="' + tabPaneHash + '"]').tab('show'); } - $('.nav-pills a').click(function(e) { + $('.nav-pills a').click(function (e) { $(this).tab('show'); const scrollmem = $('body').scrollTop(); window.location.hash = this.hash; From b88727940cf3a4648eddea3eb1801e9887bd5282 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Thu, 11 May 2023 11:11:22 +0200 Subject: [PATCH 4/4] clean up --- themes/default/views/admin/settings/index.blade.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/default/views/admin/settings/index.blade.php b/themes/default/views/admin/settings/index.blade.php index 3c396a8c..7c9f59b5 100644 --- a/themes/default/views/admin/settings/index.blade.php +++ b/themes/default/views/admin/settings/index.blade.php @@ -77,13 +77,13 @@ @endif @endforeach - + -

+