mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
edit orange pills
This commit is contained in:
@@ -21,6 +21,8 @@ class CommentBookCase extends Component
|
||||
|
||||
public BookCase $bookCase;
|
||||
|
||||
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.book-case.comment-book-case')
|
||||
|
||||
73
app/Http/Livewire/BookCase/Form/OrangePillForm.php
Normal file
73
app/Http/Livewire/BookCase/Form/OrangePillForm.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\BookCase\Form;
|
||||
|
||||
use App\Models\BookCase;
|
||||
use App\Models\Country;
|
||||
use App\Models\OrangePill;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
|
||||
class OrangePillForm extends Component
|
||||
{
|
||||
use WithFileUploads;
|
||||
|
||||
public Country $country;
|
||||
|
||||
public BookCase $bookCase;
|
||||
public ?OrangePill $orangePill = null;
|
||||
|
||||
public $image;
|
||||
|
||||
public string $fromUrl = '';
|
||||
|
||||
protected $queryString = ['fromUrl' => ['except' => '']];
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'orangePill.book_case_id' => 'required',
|
||||
'orangePill.user_id' => 'required',
|
||||
'orangePill.amount' => 'required|numeric',
|
||||
'orangePill.date' => 'required|date',
|
||||
'orangePill.comment' => 'required|string',
|
||||
'image' => 'image|max:8192', // 8MB Max
|
||||
];
|
||||
}
|
||||
|
||||
public function mount()
|
||||
{
|
||||
if (!$this->orangePill) {
|
||||
$this->orangePill = new OrangePill([
|
||||
'user_id' => auth()->id(),
|
||||
'book_case_id' => $this->bookCase->id,
|
||||
'date' => now(),
|
||||
'amount' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$this->validate();
|
||||
$this->orangePill->save();
|
||||
$this->orangePill
|
||||
->addMedia($this->image)
|
||||
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
|
||||
->toMediaCollection('images');
|
||||
|
||||
return redirect($this->fromUrl);
|
||||
}
|
||||
|
||||
public function deleteMe()
|
||||
{
|
||||
$this->orangePill->delete();
|
||||
|
||||
return redirect($this->fromUrl);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.book-case.form.orange-pill-form');
|
||||
}
|
||||
}
|
||||
@@ -21,14 +21,10 @@ class WorldMap extends Component
|
||||
->map(fn($bookCase) => [
|
||||
'lat' => $bookCase->latitude,
|
||||
'lng' => $bookCase->longitude,
|
||||
'url' => url()->route('bookCases.table.bookcases',
|
||||
'url' => url()->route('bookCases.comment.bookcase',
|
||||
[
|
||||
'country' => $this->country,
|
||||
'bookcases' => [
|
||||
'filters' => [
|
||||
'byids' => $bookCase->id,
|
||||
]
|
||||
]
|
||||
'country' => $this->country,
|
||||
'bookCase' => $bookCase,
|
||||
]),
|
||||
'op' => $bookCase->orange_pills_count,
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user