parent
9c82647876
commit
ea7c14fdac
9 changed files with 32 additions and 61 deletions
@ -0,0 +1,13 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Components; // <-- đổi namespace |
||||||
|
|
||||||
|
use Livewire\Component; |
||||||
|
|
||||||
|
class Dashboard extends Component |
||||||
|
{ |
||||||
|
public function render() |
||||||
|
{ |
||||||
|
return view('components.dashboard'); |
||||||
|
} |
||||||
|
} |
@ -1,16 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace App\Http\Controllers; |
|
||||||
|
|
||||||
use Livewire\Component; |
|
||||||
|
|
||||||
class Dashboard extends Component |
|
||||||
{ |
|
||||||
public function render() |
|
||||||
{ |
|
||||||
|
|
||||||
return view('component.dashboard') |
|
||||||
->layoutData(['title' => 'Dashboard']) // truyền thêm data nếu cần |
|
||||||
->layout('layouts.app'); |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,13 @@ |
|||||||
|
<?php |
||||||
|
namespace App\Http\Controllers; |
||||||
|
|
||||||
|
use App\Http\Controllers\Controller; |
||||||
|
|
||||||
|
class DashboardController extends Controller |
||||||
|
{ |
||||||
|
public function index() |
||||||
|
{ |
||||||
|
// Trả về Blade wrapper, Livewire component sẽ được gọi trong đó |
||||||
|
return view('admin.dashboard'); |
||||||
|
} |
||||||
|
} |
@ -1,35 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
namespace App\Livewire\Auth; |
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Auth; |
|
||||||
use Livewire\Component; |
|
||||||
|
|
||||||
class Login extends Component |
|
||||||
{ |
|
||||||
public $email = ''; |
|
||||||
public $password = ''; |
|
||||||
public $remember = false; |
|
||||||
|
|
||||||
protected $rules = [ |
|
||||||
'email' => 'required|email', |
|
||||||
'password' => 'required', |
|
||||||
]; |
|
||||||
|
|
||||||
public function login() |
|
||||||
{ |
|
||||||
$this->validate(); |
|
||||||
|
|
||||||
if (Auth::attempt(['email' => $this->email, 'password' => $this->password], $this->remember)) { |
|
||||||
request()->session()->regenerate(); |
|
||||||
return redirect()->intended('/dashboard'); |
|
||||||
} |
|
||||||
|
|
||||||
$this->addError('email', 'Email hoặc mật khẩu không đúng.'); |
|
||||||
} |
|
||||||
|
|
||||||
public function render() |
|
||||||
{ |
|
||||||
return view('auth.login')->layout('layouts.auth'); |
|
||||||
} |
|
||||||
} |
|
@ -1,10 +1,8 @@ |
|||||||
{{-- resources/views/admin/dashboard.blade.php --}} |
|
||||||
@extends('layouts.app') |
@extends('layouts.app') |
||||||
|
|
||||||
@section('title', 'Dashboard') |
@section('title', 'Dashboard') |
||||||
|
|
||||||
@section('content') |
@section('content') |
||||||
|
{{-- Đây chính là chỗ Livewire inject component --}} |
||||||
{{-- Gọi Livewire component --}} |
|
||||||
<livewire:dashboard /> |
<livewire:dashboard /> |
||||||
@endsection |
@endsection |
||||||
|
Loading…
Reference in new issue