Skip to content

Commit 2988fbd

Browse files
committed
feat: add is_draft field to Plugin model and filter out drafts in plugin list query
1 parent 82cd0e4 commit 2988fbd

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

app/Actions/GetPluginsListData.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ function () use ($plugins): array {
3333
$plugins,
3434
fn (EloquentBuilder $query) => $query->whereKey($plugins),
3535
)
36+
->where(
37+
fn (EloquentBuilder $query) => $query->whereNull('is_draft')->orWhere('is_draft', false)
38+
)
3639
->orderByDesc('publish_date')
3740
->with(['author'])
3841
->get()

app/Models/Plugin.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Plugin extends Model implements Starrable
2727
'has_translations' => 'boolean',
2828
'is_lemon_squeezy_embedded' => 'boolean',
2929
'is_presale' => 'boolean',
30+
'is_draft' => 'boolean',
3031
'versions' => 'array',
3132
'publish_date' => 'date',
3233
'docs_urls' => 'array',
@@ -48,6 +49,7 @@ public static function schema(Blueprint $table)
4849
$table->string('image')->nullable();
4950
$table->boolean('is_lemon_squeezy_embedded')->nullable()->default(false);
5051
$table->boolean('is_presale')->nullable()->default(false);
52+
$table->boolean('is_draft')->nullable()->default(false);
5153
$table->string('name');
5254
$table->string('price')->nullable();
5355
$table->string('slug');
@@ -106,6 +108,11 @@ public function isFree(): bool
106108
return blank($this->price) && blank($this->anystack_id);
107109
}
108110

111+
public function isDraft(): bool
112+
{
113+
return (bool) $this->is_draft;
114+
}
115+
109116
public function getCheckoutUrl(): ?string
110117
{
111118
if (filled($this->checkout_url)) {

0 commit comments

Comments
 (0)