From 5f829504e66951e32226fb86b14c5dc493cebde6 Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Mon, 8 May 2023 22:12:09 +0200 Subject: [PATCH 1/6] Enabled publish post only in production env --- app/Console/Commands/PostArticleToTelegram.php | 8 +++++--- app/Console/Commands/PostArticleToTwitter.php | 8 +++++--- app/Console/Commands/SendWelcomeMailToUsers.php | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/Console/Commands/PostArticleToTelegram.php b/app/Console/Commands/PostArticleToTelegram.php index e93931fc..26a099a0 100644 --- a/app/Console/Commands/PostArticleToTelegram.php +++ b/app/Console/Commands/PostArticleToTelegram.php @@ -17,10 +17,12 @@ class PostArticleToTelegram extends Command public function handle(AnonymousNotifiable $notifiable): void { - if ($article = Article::nexForSharingToTelegram()) { - $notifiable->notify(new PostArticleToTelegramNotification($article)); + if (app()->environment('production')) { + if ($article = Article::nexForSharingToTelegram()) { + $notifiable->notify(new PostArticleToTelegramNotification($article)); - $article->markAsPublish(); + $article->markAsPublish(); + } } } } diff --git a/app/Console/Commands/PostArticleToTwitter.php b/app/Console/Commands/PostArticleToTwitter.php index 47904e57..6261e00c 100644 --- a/app/Console/Commands/PostArticleToTwitter.php +++ b/app/Console/Commands/PostArticleToTwitter.php @@ -17,10 +17,12 @@ class PostArticleToTwitter extends Command public function handle(AnonymousNotifiable $notifiable): void { - if ($article = Article::nextForSharing()) { - $notifiable->notify(new PostArticleToTwitterNotification($article)); + if (app()->environment('production')) { + if ($article = Article::nextForSharing()) { + $notifiable->notify(new PostArticleToTwitterNotification($article)); - $article->markAsShared(); + $article->markAsShared(); + } } } } diff --git a/app/Console/Commands/SendWelcomeMailToUsers.php b/app/Console/Commands/SendWelcomeMailToUsers.php index d18ce6d7..f6f4095b 100644 --- a/app/Console/Commands/SendWelcomeMailToUsers.php +++ b/app/Console/Commands/SendWelcomeMailToUsers.php @@ -4,6 +4,7 @@ namespace App\Console\Commands; +use App\Mail\Welcome; use App\Models\User; use Illuminate\Console\Command; use Illuminate\Support\Facades\Mail; @@ -17,7 +18,7 @@ class SendWelcomeMailToUsers extends Command public function handle(): void { foreach (User::all() as $user) { - Mail::to($user)->queue(new \App\Mail\Welcome($user)); + Mail::to($user)->queue(new Welcome($user)); } } } From bc424daa8672445c182a0c6d27275af258a93c53 Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Mon, 8 May 2023 22:12:51 +0200 Subject: [PATCH 2/6] Add sponsors list on sponsor page --- app/Http/Controllers/SponsoringController.php | 18 ++++++- app/Models/Transaction.php | 7 +++ package.json | 1 + resources/js/app.js | 2 + .../components/dropdown-profile.blade.php | 6 +-- .../components/sponsor-profile.blade.php | 47 +++++++++++++++++++ resources/views/sponsors/index.blade.php | 13 +++-- 7 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 resources/views/components/sponsor-profile.blade.php diff --git a/app/Http/Controllers/SponsoringController.php b/app/Http/Controllers/SponsoringController.php index 12f3c138..b6b16a85 100644 --- a/app/Http/Controllers/SponsoringController.php +++ b/app/Http/Controllers/SponsoringController.php @@ -4,12 +4,28 @@ namespace App\Http\Controllers; +use App\Models\Transaction; use Illuminate\Contracts\View\View; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\DB; class SponsoringController extends Controller { public function sponsors(): View { - return view('sponsors.index'); +// $sponsors = Cache::remember( +// 'sponsors', +// 3600, +// fn () => Transaction::with('user') +// ->scopes('complete') +// ->get(['id', 'user_id', 'metadata']) +// ); + $sponsors = Transaction::with('user') + ->scopes('complete') + ->get(['id', 'user_id', 'metadata']); + + return view('sponsors.index', [ + 'sponsors' => $sponsors + ]); } } diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index eb1588e9..9505b3bc 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -4,6 +4,8 @@ namespace App\Models; +use App\Enums\TransactionStatus; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -28,6 +30,11 @@ public function user(): BelongsTo return $this->belongsTo(User::class); } + public function scopeComplete(Builder $query): Builder + { + return $query->where('status', TransactionStatus::COMPLETE->value); + } + public function getMetadata(string $name, string $default = ''): string | array { if ($this->metadata && array_key_exists($name, $this->metadata)) { diff --git a/package.json b/package.json index c2263f4c..bdefbe85 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@alpinejs/intersect": "^3.6.1", "@headlessui/react": "^1.7.2", "@heroicons/react": "^2.0.11", + "@ryangjchandler/alpine-tooltip": "^1.2.0", "axios": "^0.21.1", "canvas-confetti": "^1.4.0", "choices.js": "^9.0.1", diff --git a/resources/js/app.js b/resources/js/app.js index 921beeed..1274e7e7 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1,6 +1,7 @@ import Alpine from 'alpinejs' import intersect from '@alpinejs/intersect' import AlpineFloatingUI from '@awcodes/alpine-floating-ui' +import Tooltip from '@ryangjchandler/alpine-tooltip' import NotificationsAlpinePlugin from '../../vendor/filament/notifications/dist/module.esm' import internationalNumber from './plugins/internationalNumber' @@ -16,6 +17,7 @@ registerHeader() Alpine.plugin(AlpineFloatingUI) Alpine.plugin(intersect) Alpine.plugin(NotificationsAlpinePlugin) +Alpine.plugin(Tooltip) Alpine.data('internationalNumber', internationalNumber) window.Alpine = Alpine diff --git a/resources/views/components/dropdown-profile.blade.php b/resources/views/components/dropdown-profile.blade.php index b4461d13..92932264 100644 --- a/resources/views/components/dropdown-profile.blade.php +++ b/resources/views/components/dropdown-profile.blade.php @@ -49,7 +49,7 @@ class="origin-top-right absolute right-0 mt-2 w-60 rounded-md shadow-lg py-1 bg- - Off + {{ __('Off') }}
@@ -72,7 +72,7 @@ class="origin-top-right absolute right-0 mt-2 w-60 rounded-md shadow-lg py-1 bg-
- Profil incomplet! + {{ __('Profil incomplet!') }} @@ -81,7 +81,7 @@ class="origin-top-right absolute right-0 mt-2 w-60 rounded-md shadow-lg py-1 bg- {{ __('Nous avons besoin de plus d\'informations pour vous mettre en relation avec les entreprises.') }}

- Compléter mon profil + {{ __('Compléter mon profil') }}
diff --git a/resources/views/components/sponsor-profile.blade.php b/resources/views/components/sponsor-profile.blade.php new file mode 100644 index 00000000..8663f873 --- /dev/null +++ b/resources/views/components/sponsor-profile.blade.php @@ -0,0 +1,47 @@ +@props(['sponsor']) + +
  • + + + @if($sponsor->getMetadata('merchant')['laravel_cm_id']) + + @else + + + + @endif + +
  • diff --git a/resources/views/sponsors/index.blade.php b/resources/views/sponsors/index.blade.php index f5dca5b1..ce999644 100644 --- a/resources/views/sponsors/index.blade.php +++ b/resources/views/sponsors/index.blade.php @@ -74,9 +74,7 @@

    -
    -

    {{ __('Sponsors') }}

    -
    +

    {{ __('Sponsors') }}

    +
    +
      + @foreach($sponsors as $sponsor) + + @endforeach +
    +
    -
    +
    From d44e65f54eb3cb97d2d3b6bfb949516ad6519909 Mon Sep 17 00:00:00 2001 From: Arthur Monney Date: Mon, 8 May 2023 23:24:54 +0200 Subject: [PATCH 3/6] :lipstick: Update user avatar --- resources/views/articles/show.blade.php | 8 +++++--- .../components/articles/card-with-author.blade.php | 2 +- resources/views/components/articles/card.blade.php | 4 +++- .../views/components/articles/overview.blade.php | 6 ++++-- .../components/discussions/overview.blade.php | 2 +- .../views/components/discussions/summary.blade.php | 4 ++-- .../views/components/dropdown-profile.blade.php | 4 ++-- .../views/components/forum/thread-author.blade.php | 2 +- .../components/forum/thread-overview.blade.php | 2 +- .../components/forum/thread-summary.blade.php | 8 ++++---- resources/views/components/user/avatar.blade.php | 14 ++++++++++++++ .../views/discussions/_contributions.blade.php | 2 +- resources/views/forum/_channels.blade.php | 6 +++--- resources/views/forum/_moderators.blade.php | 8 +++++--- resources/views/forum/create.blade.php | 2 +- resources/views/forum/edit.blade.php | 2 +- resources/views/forum/index.blade.php | 2 +- resources/views/forum/thread.blade.php | 6 ++++-- resources/views/home.blade.php | 4 ++-- resources/views/livewire/forum/reply.blade.php | 2 +- resources/views/sponsors/index.blade.php | 2 +- resources/views/user/profile.blade.php | 6 +++++- 22 files changed, 63 insertions(+), 35 deletions(-) create mode 100644 resources/views/components/user/avatar.blade.php diff --git a/resources/views/articles/show.blade.php b/resources/views/articles/show.blade.php index cc53a667..c2240f37 100644 --- a/resources/views/articles/show.blade.php +++ b/resources/views/articles/show.blade.php @@ -14,12 +14,14 @@