mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
nostr events added
This commit is contained in:
39
app/Console/Commands/Nostr/PublishUnpublishedItems.php
Normal file
39
app/Console/Commands/Nostr/PublishUnpublishedItems.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Nostr;
|
||||
|
||||
use App\Traits\NostrTrait;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class PublishUnpublishedItems extends Command
|
||||
{
|
||||
use NostrTrait;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'nostr:publish {--model=}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$modelName = $this->option('model');
|
||||
$className = '\\App\Models\\'.$modelName;
|
||||
$model = $className::query()
|
||||
->whereNull('nostr_status')
|
||||
->when($modelName === 'BitcoinEvent', fn($q) => $q->where('from', '>', now()))
|
||||
->when($modelName === 'CourseEvent', fn($q) => $q->where('from', '>', now()))
|
||||
->when($modelName === 'MeetupEvent', fn($q) => $q->where('start', '>', now()))
|
||||
->first();
|
||||
$this->publishOnNostr($model, $this->getText($model));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user