Adding LoginForm Livewire component
This commit is contained in:
parent
d40008aafc
commit
62b32d36e7
2 changed files with 60 additions and 0 deletions
43
app/Http/Livewire/Form/LoginForm.php
Normal file
43
app/Http/Livewire/Form/LoginForm.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Form;
|
||||
|
||||
use Livewire\Component;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class LoginForm extends Component
|
||||
{
|
||||
public $username;
|
||||
|
||||
public $password;
|
||||
|
||||
protected $rules = [
|
||||
'username' => 'required|string|min:3',
|
||||
'password' => 'required|string',
|
||||
];
|
||||
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
|
||||
$cred = [
|
||||
'username' => $this->username,
|
||||
'password' => $this->password
|
||||
];
|
||||
|
||||
if (!Auth::attempt($cred)) {
|
||||
session()->flash('message', __('auth.failed'));
|
||||
return;
|
||||
}
|
||||
|
||||
return redirect()->intended('/admin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the setup page
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('form.login');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue