-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
244 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Forms; | ||
|
||
use App\Models\Venue; | ||
use Livewire\Form; | ||
|
||
class VenueForm extends Form | ||
{ | ||
public ?Venue $venueModel; | ||
|
||
public ?string $name; | ||
|
||
public function rules(): array | ||
{ | ||
return [ | ||
'name' => 'required|string', | ||
]; | ||
} | ||
|
||
public function setVenueModel(Venue $venueModel): void | ||
{ | ||
$this->venueModel = $venueModel; | ||
|
||
$this->name = $this->venueModel->name; | ||
} | ||
|
||
public function store(): void | ||
{ | ||
$this->venueModel->create($this->validate()); | ||
|
||
$this->reset(); | ||
} | ||
|
||
public function update(): void | ||
{ | ||
$this->venueModel->update($this->validate()); | ||
|
||
$this->reset(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Venues; | ||
|
||
use App\Livewire\Forms\VenueForm; | ||
use App\Models\Venue; | ||
use Illuminate\View\View; | ||
use Livewire\Attributes\Layout; | ||
use Livewire\Component; | ||
|
||
class Create extends Component | ||
{ | ||
public VenueForm $form; | ||
|
||
public function mount(Venue $venue): void | ||
{ | ||
$this->form->setVenueModel($venue); | ||
} | ||
|
||
public function save(): void | ||
{ | ||
$this->form->store(); | ||
|
||
$this->redirectRoute('venues.index', navigate: true); | ||
} | ||
|
||
#[Layout('layouts.app')] | ||
public function render(): View | ||
{ | ||
return view('livewire.venue.create'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Venues; | ||
|
||
use App\Livewire\Forms\VenueForm; | ||
use App\Models\Venue; | ||
use Illuminate\View\View; | ||
use Livewire\Attributes\Layout; | ||
use Livewire\Component; | ||
|
||
class Edit extends Component | ||
{ | ||
public VenueForm $form; | ||
|
||
public function mount(Venue $venue): void | ||
{ | ||
$this->form->setVenueModel($venue); | ||
} | ||
|
||
public function save(): void | ||
{ | ||
$this->form->update(); | ||
|
||
$this->redirectRoute('venues.index', navigate: true); | ||
} | ||
|
||
#[Layout('layouts.app')] | ||
public function render(): View | ||
{ | ||
return view('livewire.venue.edit'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Venues; | ||
|
||
use App\Models\Venue; | ||
use Illuminate\View\View; | ||
use Livewire\Attributes\Layout; | ||
use Livewire\Component; | ||
use Livewire\WithPagination; | ||
|
||
class Index extends Component | ||
{ | ||
use WithPagination; | ||
|
||
#[Layout('layouts.app')] | ||
public function render(): View | ||
{ | ||
$venues = Venue::simplePaginate(10); | ||
|
||
return view('livewire.venue.index', compact('venues')) | ||
->with('i', $this->getPage() * $venues->perPage()); | ||
} | ||
|
||
public function delete(Venue $venue): void | ||
{ | ||
$venue->delete(); | ||
|
||
$this->redirectRoute('venues.index', navigate: true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Venues; | ||
|
||
use App\Livewire\Forms\VenueForm; | ||
use App\Models\Venue; | ||
use Illuminate\View\View; | ||
use Livewire\Attributes\Layout; | ||
use Livewire\Component; | ||
|
||
class Show extends Component | ||
{ | ||
public VenueForm $form; | ||
|
||
public function mount(Venue $venue): void | ||
{ | ||
$this->form->setVenueModel($venue); | ||
} | ||
|
||
#[Layout('layouts.app')] | ||
public function render(): View | ||
{ | ||
return view('livewire.venue.show', ['venue' => $this->form->venueModel]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<x-crud.header>Venues</x-crud.header> | ||
|
||
<div class="w-full"> | ||
<x-crud.subheader back-route="venues.index">Create a new venue</x-crud.subheader> | ||
|
||
<x-crud.content class="mt-8 max-w-xl"> | ||
<form method="POST" wire:submit="save" role="form" enctype="multipart/form-data"> | ||
@csrf | ||
@include('livewire.venue.form') | ||
</form> | ||
</x-crud.content> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<x-crud.header>Venues</x-crud.header> | ||
|
||
<div class="w-full"> | ||
<x-crud.subheader back-route="venues.index">Update the {{ $this->form->venueModel->name }} venue</x-crud.subheader> | ||
|
||
<x-crud.content class="mt-8 max-w-xl"> | ||
<form method="POST" wire:submit="save" role="form" enctype="multipart/form-data"> | ||
{{ method_field('PATCH') }} | ||
@csrf | ||
@include('livewire.venue.form') | ||
</form> | ||
</x-crud.content> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="space-y-6"> | ||
<div> | ||
<x-input-label for="name" value="Name"/> | ||
<x-text-input wire:model="form.name" id="name" name="name" type="text" class="mt-1 block w-full" autocomplete="name" placeholder="Name with full address"/> | ||
@error('form.name') | ||
<x-input-error class="mt-2" :messages="$message"/> | ||
@enderror | ||
</div> | ||
|
||
<div class="flex items-center gap-4"> | ||
<x-primary-button>Save</x-primary-button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<x-crud.header>Venues</x-crud.header> | ||
|
||
<div class="w-full"> | ||
<x-crud.subheader add-route="venues.create" class="mb-4">A list of all the venues in the system</x-crud.subheader> | ||
<x-crud.content> | ||
<x-crud.index.table columns="name"> | ||
@foreach ($venues as $venue) | ||
<x-crud.index.row row-key="{{ $venue->getKey() }}"> | ||
<x-crud.index.cell>{{ $venue->name }}</x-crud.index.cell> | ||
<x-crud.index.cell class="flex gap-1 pl-2 pr-0 font-medium"> | ||
<x-crud.index.show-button route="venues.show" :model="$venue" /> | ||
<x-crud.index.edit-button route="venues.edit" :model="$venue" /> | ||
<x-crud.index.delete-button :model="$venue"> | ||
Are you sure you want to delete venue {{ $venue->name }}?" | ||
</x-crud.index.delete-button> | ||
</x-crud.index.cell> | ||
</x-crud.index.row> | ||
@endforeach | ||
</x-crud.index.table> | ||
|
||
<div class="mt-4 px-4"> | ||
{!! $venues->withQueryString()->links() !!} | ||
</div> | ||
</x-crud.content> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<x-crud.header>Venues</x-crud.header> | ||
|
||
<div class="w-full"> | ||
<x-crud.subheader back-route="venues.index">Details of the {{ $venue->name }} venue</x-crud.subheader> | ||
<x-crud.content> | ||
<x-crud.show.table> | ||
<x-crud.show.model-field label="Name">{{ $venue->name }}</x-crud.show.model-field> | ||
</x-crud.show.table> | ||
</x-crud.content> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters