Skip to content

Commit

Permalink
feat: add example livewire component
Browse files Browse the repository at this point in the history
  • Loading branch information
SlimDeluxe committed Feb 10, 2024
1 parent e6dd99a commit 4078ae0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
24 changes: 24 additions & 0 deletions app/Livewire/Counter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Livewire;

use Livewire\Component;

class Counter extends Component
{
public $count = 1;

public function increment()
{
$this->count++;
}

public function decrement()
{
$this->count--;
}
public function render()
{
return view('livewire.counter');
}
}
4 changes: 3 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace App\Providers;

use App\Livewire\Counter;
use Illuminate\Support\ServiceProvider;
use Livewire;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -19,6 +21,6 @@ public function register(): void
*/
public function boot(): void
{
//
Livewire::component('counter', Counter::class);
}
}
7 changes: 7 additions & 0 deletions resources/views/example.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@
<p>
This is the example view in the skeleton app!
</p>

<p class="mt-5">Here's a Livewire component from the skeleton.</p>
<livewire:counter/>

<p class="mt-5">And here's a Livewire component from the module template:</p>
<livewire:my-counter/>

</div>
</x-app-layout>
7 changes: 7 additions & 0 deletions resources/views/livewire/counter.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div>
<h1>{{ $count }}</h1>

<button wire:click="increment">+</button>

<button wire:click="decrement">-</button>
</div>

0 comments on commit 4078ae0

Please sign in to comment.