Skip to content

MEP into Main #364

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 21 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c90229c
chore(deps): bump vormkracht10/filament-mails from 1.0.5 to 2.0.1 (#301)
dependabot[bot] Jan 11, 2025
e2a741c
Merge branch 'develop' of https://github.com/laravelcm/laravel.cm int…
StevyMarlino Jan 11, 2025
fb3acd6
chore(deps): bump dependabot/fetch-metadata from 2.2.0 to 2.3.0
dependabot[bot] Jan 27, 2025
3278ed6
Merge branch 'develop' of https://github.com/laravelcm/laravel.cm int…
StevyMarlino Feb 20, 2025
6d9f84d
feat: LAR-175 upgrade the approbation system
StevyMarlino Mar 9, 2025
700bdf1
chore(deps): bump dependabot/fetch-metadata from 2.2.0 to 2.3.0 (#325)
github-actions[bot] Mar 10, 2025
f313a47
feat: LAR-175 udpdate type of reason
StevyMarlino Mar 10, 2025
6dc96f1
feat: LAR-175 upgrade the approbation system (#340)
StevyMarlino Mar 10, 2025
fb5a581
Merge branch 'develop' of https://github.com/laravelcm/laravel.cm int…
StevyMarlino Mar 24, 2025
f356289
Feature/lar 184 discussion double notification send (#343)
StevyMarlino Mar 24, 2025
4e801ee
Merge branch 'develop' of https://github.com/laravelcm/laravel.cm int…
StevyMarlino Mar 26, 2025
22af1bf
feat: LAR-0189 init modular configuration'
StevyMarlino Apr 1, 2025
dd73e16
fix: LAR-0189 fix format file style
StevyMarlino Apr 1, 2025
a9d878b
feat: wip
StevyMarlino Apr 1, 2025
427ff35
Feature/lar 0189 config modular (#348)
StevyMarlino Apr 1, 2025
5b62124
feat: LAR-0192 update stub
StevyMarlino Apr 1, 2025
cf0cf24
feat: LAR-0192 update stub (#349)
StevyMarlino Apr 1, 2025
ac82439
feat: LAR-354 publish admin article automatically
StevyMarlino Apr 7, 2025
7d5d35b
feat: LAR-354 publish admin article automatically (#354)
StevyMarlino Apr 7, 2025
d56d81a
feat: LAR-363 fixing sponsoring payment error
StevyMarlino May 2, 2025
36f783c
feat: LAR-363 fixing sponsoring payment error (#363)
StevyMarlino May 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2.2.0
uses: dependabot/fetch-metadata@v2.3.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Auto-merge Dependabot PRs for semver-minor updates
Expand Down
22 changes: 21 additions & 1 deletion app/Actions/Article/CreateArticleAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,35 @@ public function execute(ArticleData $articleData): Article
);
}

$user = Auth::user();

if ($user->isAdmin() || $user->isModerator()) {
$articleData->published_at = new Carbon(
time: today(),
timezone: config('app.timezone')
);

$articleData->submitted_at = new Carbon(
time: $articleData->submitted_at,
timezone: config('app.timezone')
);

$articleData->approved_at = new Carbon(
time: today(),
timezone: config('app.timezone')
);
}

// @phpstan-ignore-next-line
return Article::query()->create([
'title' => $articleData->title,
'slug' => $articleData->slug,
'body' => $articleData->body,
'published_at' => $articleData->published_at,
'submitted_at' => $articleData->submitted_at,
'approved_at' => $articleData->approved_at,
'canonical_url' => $articleData->canonical_url,
'user_id' => Auth::id(),
'user_id' => $user->id,
]);
}
}
31 changes: 31 additions & 0 deletions app/Actions/Article/DeclineArticleAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace App\Actions\Article;

use App\Models\Article;
use App\Notifications\ArticleDeclinedNotification;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;

final class DeclineArticleAction
{
public function execute(string $reason, Article $article): Article
{
return DB::transaction(function () use ($reason, $article) {

$article->update([
'declined_at' => Carbon::now(),
'reason' => $reason,
'submitted_at' => null,
]);

$article->user->notify(new ArticleDeclinedNotification($article));

$article->refresh();

return $article;
});
}
}
4 changes: 4 additions & 0 deletions app/Actions/Article/UpdateArticleAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public function execute(ArticleData $articleData, Article $article): Article
);
}

if ($articleData->declined_at) {
$articleData->declined_at = null;
}

$article->update($articleData->toArray());

$article->refresh();
Expand Down
2 changes: 2 additions & 0 deletions app/Data/ArticleData.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ public function __construct(
public ?string $canonical_url = null,
public ?Carbon $published_at = null,
public ?Carbon $submitted_at = null,
public ?Carbon $declined_at = null,
public ?Carbon $approved_at = null,
) {}
}
26 changes: 20 additions & 6 deletions app/Filament/Resources/ArticleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
namespace App\Filament\Resources;

use App\Actions\Article\ApprovedArticleAction;
use App\Actions\Article\DeclineArticleAction;
use App\Filament\Resources\ArticleResource\Pages;
use App\Models\Article;
use Awcodes\FilamentBadgeableColumn\Components\Badge;
use Awcodes\FilamentBadgeableColumn\Components\BadgeableColumn;
use Filament\Forms\Components\Textarea;
use Filament\Notifications\Notification;
use Filament\Resources\Resource;
use Filament\Support\Enums\MaxWidth;
use Filament\Tables;
Expand Down Expand Up @@ -99,7 +102,6 @@ public static function table(Table $table): Table

return '';
})
->searchable()
->sortable(),
])
->actions([
Expand All @@ -123,15 +125,27 @@ public static function table(Table $table): Table
->label('Décliner')
->icon('heroicon-s-x-mark')
->color('warning')
->modalHeading(__('Voulez vous décliner cet article'))
->successNotificationTitle(__('Opération effectuée avec succès'))
->form([
Textarea::make('reason')
->label(__('Raison du refus'))
->maxLength(255)
->required(),
])
->modalHeading('Décliner l\'article')
->modalDescription('Veuillez fournir une raison détaillée pour le refus de cet article. L\'auteur recevra cette explication.')
->successNotificationTitle('Article décliné avec succès')
->requiresConfirmation()
->modalIcon('heroicon-s-x-mark')
->action(function ($record): void {
->action(function (array $data, Article $record): void {
Gate::authorize('decline', $record);

$record->declined_at = now();
$record->save();
app(DeclineArticleAction::class)->execute($data['reason'], $record);

Notification::make()
->title('Article décliné')
->body('L\'auteur a été notifié de la raison du refus.')
->success()
->send();
}),
Tables\Actions\Action::make('show')
->icon('untitledui-eye')
Expand Down
10 changes: 10 additions & 0 deletions app/Filament/Resources/ArticleResource/Pages/ListArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Filament\Resources\ArticleResource;
use App\Models\Article;
use Closure;
use Filament\Resources\Components\Tab;
use Filament\Resources\Pages\ListRecords;

final class ListArticles extends ListRecords
Expand All @@ -17,4 +18,13 @@ public function isTableRecordSelectable(): Closure
{
return fn (Article $record): bool => $record->isNotPublished();
}

public function getTabs(): array
{
return [
'En attente' => Tab::make()->query(fn ($query) => $query->awaitingApproval()),
'Apprové' => Tab::make()->query(fn ($query) => $query->published()),
'Décliné' => Tab::make()->query(fn ($query) => $query->declined()),
];
}
}
2 changes: 1 addition & 1 deletion app/Livewire/Components/SponsorSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function submit(): void
'status' => $payload->transaction->status,
'transaction_reference' => $payload->transaction->reference,
'user_id' => $user->id,
'fees' => $payload->transaction->fee,
'fees' => empty(get_object_vars($payload->transaction->fees)) ? 0 : $payload->transaction->fees->fee,
'type' => TransactionType::ONETIME->value,
'metadata' => [
'currency' => $payload->transaction->currency,
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* @property bool $is_pinned
* @property int $is_sponsored
* @property string | null $canonical_url
* @property string | null $reason
* @property int | null $tweet_id
* @property int $user_id
* @property string | null $locale
Expand Down Expand Up @@ -63,6 +64,7 @@ final class Article extends Model implements HasMedia, ReactableInterface, Sitem
'body',
'slug',
'canonical_url',
'reason',
'show_toc',
'is_pinned',
'user_id',
Expand Down
41 changes: 41 additions & 0 deletions app/Notifications/ArticleDeclinedNotification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace App\Notifications;

use App\Models\Article;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

final class ArticleDeclinedNotification extends Notification
{
use Queueable;

public function __construct(public Article $article) {}

public function via(mixed $notifiable): array
{
return ['mail', 'database'];
}

public function toMail(mixed $notifiable): MailMessage
{
return (new MailMessage)
->subject(__('emails/article.article_declined.subject'))
->markdown('emails.article_declined', ['article' => $this->article]);
}

/**
* @return array<string, mixed>
*/
public function toArray(): array
{
return [
'article' => $this->article,
'owner' => $this->article->user->name,
'email' => $this->article->user->email,
];
}
}
7 changes: 0 additions & 7 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@
use App\Events\CommentWasAdded;
use App\Events\ReplyWasCreated;
use App\Events\SponsoringPaymentInitialize;
use App\Events\ThreadWasCreated;
use App\Events\UserBannedEvent;
use App\Events\UserUnbannedEvent;
// use App\Listeners\SendCompanyEmailVerificationNotification;
use App\Listeners\NotifyMentionedUsers;
use App\Listeners\PostNewThreadNotification;
use App\Listeners\SendBanNotificationListener;
use App\Listeners\SendNewArticleNotification;
use App\Listeners\SendNewCommentNotification;
// use App\Listeners\SendWelcomeCompanyNotification;
use App\Listeners\SendNewReplyNotification;
use App\Listeners\SendNewThreadNotification;
use App\Listeners\SendPaymentNotification;
use App\Listeners\SendUnbanNotificationListener;
use App\Listeners\SendWelcomeMailNotification;
Expand All @@ -42,10 +39,6 @@ final class EventServiceProvider extends ServiceProvider
SendNewReplyNotification::class,
NotifyMentionedUsers::class,
],
ThreadWasCreated::class => [
SendNewThreadNotification::class,
PostNewThreadNotification::class,
],
ArticleWasSubmittedForApproval::class => [
SendNewArticleNotification::class,
],
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"gehrisandro/tailwind-merge-laravel": "^1.2",
"graham-campbell/markdown": "^15.2",
"guzzlehttp/guzzle": "^7.7.0",
"internachi/modular": "^2.3",
"jenssegers/agent": "^2.6.4",
"laravel-notification-channels/telegram": "^5.0",
"laravel-notification-channels/twitter": "^8.1",
Expand Down
Loading
Loading