Skip to content

Commit

Permalink
feat: add is_draft field to Plugin model and filter out drafts in plu…
Browse files Browse the repository at this point in the history
…gin list query
  • Loading branch information
saade committed Jan 7, 2025
1 parent 82cd0e4 commit 2988fbd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/Actions/GetPluginsListData.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ function () use ($plugins): array {
$plugins,
fn (EloquentBuilder $query) => $query->whereKey($plugins),
)
->where(
fn (EloquentBuilder $query) => $query->whereNull('is_draft')->orWhere('is_draft', false)
)
->orderByDesc('publish_date')
->with(['author'])
->get()
Expand Down
7 changes: 7 additions & 0 deletions app/Models/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Plugin extends Model implements Starrable
'has_translations' => 'boolean',
'is_lemon_squeezy_embedded' => 'boolean',
'is_presale' => 'boolean',
'is_draft' => 'boolean',
'versions' => 'array',
'publish_date' => 'date',
'docs_urls' => 'array',
Expand All @@ -48,6 +49,7 @@ public static function schema(Blueprint $table)
$table->string('image')->nullable();
$table->boolean('is_lemon_squeezy_embedded')->nullable()->default(false);
$table->boolean('is_presale')->nullable()->default(false);
$table->boolean('is_draft')->nullable()->default(false);
$table->string('name');
$table->string('price')->nullable();
$table->string('slug');
Expand Down Expand Up @@ -106,6 +108,11 @@ public function isFree(): bool
return blank($this->price) && blank($this->anystack_id);
}

public function isDraft(): bool
{
return (bool) $this->is_draft;
}

public function getCheckoutUrl(): ?string
{
if (filled($this->checkout_url)) {
Expand Down

0 comments on commit 2988fbd

Please sign in to comment.