Created
May 13, 2023 18:02
-
-
Save mansha99/f80a0b7980329c275ae1a8fb706bdd83 to your computer and use it in GitHub Desktop.
A Laravel Livewire component displaying Livewire validation in action
This file contains hidden or 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
<?php | |
namespace App\Http\Livewire; | |
use Livewire\Component; | |
class Calculator extends Component | |
{ | |
public $n1; | |
public $n2; | |
public $result=''; | |
protected $rules = [ | |
'n1' => 'required|numeric|min:1', | |
'n2' => 'required|numeric|min:1', | |
]; | |
public function multiply() | |
{ | |
$this->validate(); | |
$this->result = $this->n1 *$this->n2; | |
} | |
public function render() | |
{ | |
return view('livewire.calculator'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment