mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-01-26 05:23:19 +00:00
🗑️ Remove election-related blade files no longer in use
This commit is contained in:
70
app/Livewire/Association/ProjectSupport/Form/Create.php
Normal file
70
app/Livewire/Association/ProjectSupport/Form/Create.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Association\ProjectSupport\Form;
|
||||
|
||||
use App\Livewire\Forms\ProjectProposalForm;
|
||||
use App\Support\NostrAuth;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
|
||||
final class Create extends Component
|
||||
{
|
||||
use WithFileUploads;
|
||||
|
||||
public ProjectProposalForm $form;
|
||||
|
||||
public ?\Illuminate\Http\UploadedFile $image = null;
|
||||
|
||||
public bool $isAllowed = false;
|
||||
|
||||
public ?string $currentPubkey = null;
|
||||
|
||||
protected $listeners = [
|
||||
'nostrLoggedIn' => 'handleNostrLoggedIn',
|
||||
'nostrLoggedOut' => 'handleNostrLoggedOut',
|
||||
];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
if (NostrAuth::check()) {
|
||||
$this->currentPubkey = NostrAuth::pubkey();
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $this->currentPubkey)->first();
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function handleNostrLoggedIn($pubkey): void
|
||||
{
|
||||
NostrAuth::login($pubkey);
|
||||
$this->currentPubkey = $pubkey;
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
|
||||
public function handleNostrLoggedOut(): void
|
||||
{
|
||||
$this->isAllowed = false;
|
||||
$this->currentPubkey = null;
|
||||
$this->currentPleb = null;
|
||||
}
|
||||
|
||||
public function save(): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$this->form->validate();
|
||||
|
||||
$projectProposal = \App\Models\ProjectProposal::query()->create([
|
||||
...$this->form->all(),
|
||||
'einundzwanzig_pleb_id' => $this->currentPleb->id,
|
||||
]);
|
||||
if ($this->image) {
|
||||
$this->validate([
|
||||
'image' => 'image|max:1024',
|
||||
]);
|
||||
$projectProposal
|
||||
->addMedia($this->image->getRealPath())
|
||||
->toMediaCollection('main');
|
||||
}
|
||||
|
||||
return redirect()->route('association.projectSupport');
|
||||
}
|
||||
}
|
||||
75
app/Livewire/Association/ProjectSupport/Form/Edit.php
Normal file
75
app/Livewire/Association/ProjectSupport/Form/Edit.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Association\ProjectSupport\Form;
|
||||
|
||||
use App\Livewire\Forms\ProjectProposalForm;
|
||||
use App\Models\ProjectProposal;
|
||||
use App\Support\NostrAuth;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
|
||||
final class Edit extends Component
|
||||
{
|
||||
use WithFileUploads;
|
||||
|
||||
public ProjectProposalForm $form;
|
||||
|
||||
public ?ProjectProposal $projectProposal = null;
|
||||
|
||||
public ?\Illuminate\Http\UploadedFile $image = null;
|
||||
|
||||
public bool $isAllowed = false;
|
||||
|
||||
public ?string $currentPubkey = null;
|
||||
|
||||
protected $listeners = [
|
||||
'nostrLoggedIn' => 'handleNostrLoggedIn',
|
||||
'nostrLoggedOut' => 'handleNostrLoggedOut',
|
||||
];
|
||||
|
||||
public function mount(ProjectProposal $projectProposal): void
|
||||
{
|
||||
if (NostrAuth::check()) {
|
||||
$this->currentPubkey = NostrAuth::pubkey();
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $this->currentPubkey)->first();
|
||||
$this->isAllowed = true;
|
||||
$this->form->fill($projectProposal->toArray());
|
||||
$this->projectProposal = $projectProposal;
|
||||
$this->image = $projectProposal->getFirstMedia('main');
|
||||
}
|
||||
}
|
||||
|
||||
public function handleNostrLoggedIn($pubkey): void
|
||||
{
|
||||
NostrAuth::login($pubkey);
|
||||
$this->currentPubkey = $pubkey;
|
||||
$this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first();
|
||||
$this->isAllowed = true;
|
||||
}
|
||||
|
||||
public function handleNostrLoggedOut(): void
|
||||
{
|
||||
$this->isAllowed = false;
|
||||
$this->currentPubkey = null;
|
||||
$this->currentPleb = null;
|
||||
}
|
||||
|
||||
public function save(): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$this->form->validate();
|
||||
if ($this->image && method_exists($this->image, 'temporaryUrl')) {
|
||||
$this->validate([
|
||||
'image' => 'nullable|image|max:1024',
|
||||
]);
|
||||
$this->projectProposal
|
||||
->addMedia($this->image->getRealPath())
|
||||
->toMediaCollection('main');
|
||||
}
|
||||
|
||||
$this->projectProposal->update([
|
||||
...$this->form->except('id', 'slug'),
|
||||
]);
|
||||
|
||||
return redirect()->route('association.projectSupport');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user