Skip to content

Commit 11c3da3

Browse files
committed
chore: apply rebase
1 parent 333d46f commit 11c3da3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+700
-1244
lines changed

app/Actions/Article/CreateArticleAction.php

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,36 @@
55
namespace App\Actions\Article;
66

77
use App\Data\CreateArticleData;
8-
use App\Gamify\Points\ArticleCreated;
98
use App\Models\Article;
10-
use App\Notifications\PostArticleToTelegram;
9+
use App\Models\User;
1110
use Carbon\Carbon;
1211
use Illuminate\Support\Facades\Auth;
1312

1413
final class CreateArticleAction
1514
{
1615
public function execute(CreateArticleData $articleData): Article
1716
{
18-
if ($articleData->publishedAt) {
19-
$articleData->publishedAt = new Carbon(
20-
time: $articleData->publishedAt,
17+
if ($articleData->published_at) {
18+
$articleData->published_at = new Carbon(
19+
time: $articleData->published_at,
2120
tz: config('app.timezone')
2221
);
2322
}
2423

24+
/** @var User $author */
25+
$author = Auth::user();
26+
2527
/** @var Article $article */
2628
$article = Article::query()->create([
2729
'title' => $articleData->title,
28-
'slug' => $articleData->title,
30+
'slug' => $articleData->slug,
2931
'body' => $articleData->body,
30-
'published_at' => $articleData->publishedAt,
31-
'submitted_at' => $articleData->submittedAt,
32-
'approved_at' => $articleData->approvedAt,
33-
'show_toc' => $articleData->showToc,
34-
'canonical_url' => $articleData->canonicalUrl,
35-
'user_id' => Auth::id(),
32+
'published_at' => $articleData->published_at,
33+
'submitted_at' => $articleData->is_draft ? null : now(),
34+
'canonical_url' => $articleData->canonical_url,
35+
'user_id' => $author->id,
3636
]);
3737

38-
if (collect($articleData->tags)->isNotEmpty()) {
39-
$article->syncTags(tags: $articleData->tags);
40-
}
41-
42-
if ($articleData->file) {
43-
$article->addMedia($articleData->file->getRealPath())
44-
->toMediaCollection('media');
45-
}
46-
47-
if ($article->isAwaitingApproval()) {
48-
// Envoi de la notification sur le channel Telegram pour la validation de l'article.
49-
Auth::user()?->notify(new PostArticleToTelegram($article));
50-
51-
session()->flash('status', __('notifications.article.created'));
52-
}
53-
54-
if (Auth::user()?->hasAnyRole(['admin', 'moderator'])) {
55-
givePoint(new ArticleCreated($article));
56-
}
57-
5838
return $article;
5939
}
6040
}

app/Data/CreateArticleData.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace App\Data;
66

77
use Carbon\Carbon;
8-
use Illuminate\Http\UploadedFile;
98
use Spatie\LaravelData\Data;
109

1110
final class CreateArticleData extends Data
@@ -14,12 +13,8 @@ public function __construct(
1413
public string $title,
1514
public string $slug,
1615
public string $body,
17-
public string $showToc,
18-
public string $canonicalUrl,
19-
public ?Carbon $publishedAt,
20-
public ?Carbon $submittedAt,
21-
public ?Carbon $approvedAt,
22-
public ?UploadedFile $file,
23-
public array $tags = [],
16+
public string $canonical_url,
17+
public ?Carbon $published_at,
18+
public bool $is_draft = false,
2419
) {}
2520
}

app/Filament/Resources/ArticleResource.php

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,12 @@ public static function table(Table $table): Table
3030
TextColumn::make('title')
3131
->label('Titre')
3232
->sortable(),
33-
TextColumn::make('status')
34-
->getStateUsing(function ($record) {
35-
if ($record->approved_at) {
36-
return 'Approuver';
37-
} elseif ($record->declined_at) {
38-
return 'Décliner';
39-
} elseif ($record->submitted_at) {
40-
return 'Soumis';
41-
} else {
42-
return 'Brouillon';
43-
}
44-
})
45-
->colors([
46-
'success' => 'Approuver',
47-
'danger' => 'Décliner',
48-
'warning' => 'Soumis',
49-
'default' => 'Brouillon',
50-
])
51-
->badge(),
52-
TextColumn::make('submitted_at')
53-
->label('Date de soumission')
54-
->dateTime(),
5533
TextColumn::make('user.name')
5634
->label('Auteur')
5735
->sortable(),
36+
TextColumn::make('submitted_at')
37+
->label('Date de soumission')
38+
->dateTime(),
5839
])
5940
->filters([
6041
Filter::make('submitted_at')->query(fn (Builder $query) => $query->whereNotNull('submitted_at'))->label('Soumis'),
@@ -90,9 +71,8 @@ public static function table(Table $table): Table
9071
$record->declined_at = now();
9172
$record->save();
9273
}),
93-
Tables\Actions\DeleteAction::make('delete'),
74+
Tables\Actions\DeleteAction::make(),
9475
]),
95-
9676
])
9777
->bulkActions([
9878
Tables\Actions\BulkActionGroup::make([
@@ -105,8 +85,8 @@ public static function table(Table $table): Table
10585
->requiresConfirmation()
10686
->modalIcon('heroicon-s-check')
10787
->modalHeading('Approuver')
108-
->modalSubheading('Voulez-vous vraiment approuver ces articles ?')
109-
->modalButton('Confirmer'),
88+
->modalDescription('Voulez-vous vraiment approuver ces articles ?')
89+
->modalSubmitActionLabel('Confirmer'),
11090
BulkAction::make('declined')
11191
->label('Décliner la sélection')
11292
->icon('heroicon-s-x-mark')
@@ -116,8 +96,8 @@ public static function table(Table $table): Table
11696
->requiresConfirmation()
11797
->modalIcon('heroicon-s-x-mark')
11898
->modalHeading('Décliner')
119-
->modalSubheading('Voulez-vous vraiment décliner ces articles ?')
120-
->modalButton('Confirmer'),
99+
->modalDescription('Voulez-vous vraiment décliner ces articles ?')
100+
->modalSubmitActionLabel('Confirmer'),
121101

122102
Tables\Actions\DeleteBulkAction::make(),
123103
]),

app/Gamify/Points/ArticleCreated.php renamed to app/Gamify/Points/ArticlePublished.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use App\Models\Article;
88
use QCod\Gamify\PointType;
99

10-
final class ArticleCreated extends PointType
10+
final class ArticlePublished extends PointType
1111
{
1212
public int $points = 50;
1313

app/Http/Controllers/ArticlesController.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

app/Livewire/Articles/Create.php

Lines changed: 0 additions & 74 deletions
This file was deleted.

app/Livewire/Articles/Edit.php

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)