feat: implement assets and blades layouts
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Enums\AdminStatus;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Admin\authLoginPostRequest;
|
||||
use App\Models\Admin;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function login()
|
||||
{
|
||||
$rawLayout = true;
|
||||
$title = 'ورود به حساب کاربری';
|
||||
|
||||
return view('admin.login', compact('rawLayout', 'title'));
|
||||
}
|
||||
|
||||
public function loginPost(authLoginPostRequest $request)
|
||||
{
|
||||
$admin = Admin::query()
|
||||
->where('username', $request->input('username'))
|
||||
->where('status', AdminStatus::ENABLE)
|
||||
->first();
|
||||
|
||||
if (!$admin) {
|
||||
return back()->withErrors([
|
||||
'general' => 'اطلاعات وارد شده نامعتبر است'
|
||||
])->withInput();
|
||||
}
|
||||
|
||||
if (!Hash::check($request->input('password'), $admin->password)) {
|
||||
return back()->withErrors([
|
||||
'general' => 'اطلاعات وارد شده نامعتبر است'
|
||||
])->withInput();
|
||||
}
|
||||
|
||||
Auth::guard('admin')->login($admin);
|
||||
|
||||
$admin->update([
|
||||
'last_login_at' => now()
|
||||
]);
|
||||
|
||||
return redirect()->route('admin.dashboard.index');
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
Auth::guard('admin')->logout();
|
||||
|
||||
return redirect()->route('admin.auth.login.index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Flight;
|
||||
use App\Models\User;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$flightsCount = Flight::count();
|
||||
$usersCount = User::count();
|
||||
$bookingsCount = Booking::count();
|
||||
|
||||
return view('admin.dashboard', compact('flightsCount', 'usersCount', 'bookingsCount'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user