nostr events added

This commit is contained in:
HolgerHatGarKeineNode
2023-02-24 11:13:43 +01:00
parent 5fbef7d4aa
commit 235ce774f9
10 changed files with 119 additions and 105 deletions

View 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));
}
}