Update controller, views, routes
This commit is contained in:
parent
63accde561
commit
df8ec5d175
|
|
@ -192,12 +192,12 @@ public function adminLogin(Request $request)
|
|||
{
|
||||
// Validate the request
|
||||
$validator = Validator::make($request->all(), [
|
||||
'username' => 'required|string|max:255',
|
||||
'email' => 'required|email|max:255',
|
||||
'password' => 'required|string|min:6',
|
||||
], [
|
||||
'username.required' => 'Nama pengguna harus diisi.',
|
||||
'username.string' => 'Nama pengguna harus berupa string.',
|
||||
'username.max' => 'Nama pengguna maksimal 255 karakter.',
|
||||
'email.required' => 'Email harus diisi.',
|
||||
'email.email' => 'Format email tidak valid.',
|
||||
'email.max' => 'Email maksimal 255 karakter.',
|
||||
'password.required' => 'Kata sandi harus diisi.',
|
||||
'password.string' => 'Kata sandi harus berupa string.',
|
||||
'password.min' => 'Kata sandi minimal 6 karakter.',
|
||||
|
|
@ -210,22 +210,24 @@ public function adminLogin(Request $request)
|
|||
->withInput();
|
||||
}
|
||||
|
||||
// Simple authentication (replace with proper authentication in production)
|
||||
$username = $request->input('username');
|
||||
// Database authentication
|
||||
$email = $request->input('email');
|
||||
$password = $request->input('password');
|
||||
|
||||
// Demo credentials - replace with proper authentication
|
||||
if ($username === 'admin.tomat' && $password === 'admin123') {
|
||||
// Store session
|
||||
session(['admin_logged_in' => true, 'admin_username' => $username]);
|
||||
// Find user by email
|
||||
$user = \DB::table('users')->where('email', $email)->first();
|
||||
|
||||
return redirect()->route('admin.dashboard')->with('success', 'Login berhasil! Selamat datang, ' . $username);
|
||||
if ($user && \Hash::check($password, $user->password) && $user->role === 'admin') {
|
||||
// Store session
|
||||
session(['admin_logged_in' => true, 'admin_user_id' => $user->id, 'admin_name' => $user->name]);
|
||||
|
||||
return redirect()->route('admin.dashboard')->with('success', 'Login berhasil! Selamat datang, ' . $user->name);
|
||||
}
|
||||
|
||||
// Failed login
|
||||
return redirect()
|
||||
->route('admin.login')
|
||||
->withErrors(['login' => 'Nama pengguna atau kata sandi salah.'])
|
||||
->withErrors(['login' => 'Email atau kata sandi salah.'])
|
||||
->withInput($request->except('password'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,6 @@ class DatabaseSeeder extends Seeder
|
|||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
$this->call(AdminSeeder::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,9 +37,22 @@ class="sidebar-item flex items-center space-x-3 px-4 py-3 rounded-lg text-gray-7
|
|||
</a>
|
||||
</nav>
|
||||
|
||||
<!-- User Profile Section -->
|
||||
<div class="p-4 border-t border-gray-200">
|
||||
<div class="flex items-center space-x-3 px-4 py-3">
|
||||
<div class="w-8 h-8 bg-gradient-to-br from-red-400 to-pink-400 rounded-full flex items-center justify-center">
|
||||
<i class="fas fa-user text-white text-sm"></i>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<p class="text-sm font-medium text-gray-900">{{ session('admin_name', 'Admin') }}</p>
|
||||
<p class="text-xs text-gray-500">Administrator</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Logout Section -->
|
||||
<div class="p-4 border-t border-gray-200">
|
||||
<a href="{{ route('logout') }}"
|
||||
<a href="{{ route('admin.logout') }}"
|
||||
class="sidebar-item flex items-center space-x-3 px-4 py-3 rounded-lg text-red-600 hover:bg-red-50 transition-all">
|
||||
<i class="fas fa-sign-out-alt w-5"></i>
|
||||
<span>Logout</span>
|
||||
|
|
|
|||
|
|
@ -9,8 +9,11 @@
|
|||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=inter:300,400,500,600,700&display=swap" rel="stylesheet" />
|
||||
|
||||
<!-- Styles -->
|
||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||
<!-- Tailwind CSS -->
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
</head>
|
||||
<body class="bg-white">
|
||||
<!-- Navbar -->
|
||||
|
|
|
|||
|
|
@ -9,8 +9,11 @@
|
|||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=inter:300,400,500,600,700&display=swap" rel="stylesheet" />
|
||||
|
||||
<!-- Styles -->
|
||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||
<!-- Tailwind CSS -->
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||
<style>
|
||||
/* Custom styles for better focus states */
|
||||
.input-field:focus {
|
||||
|
|
@ -73,18 +76,18 @@
|
|||
|
||||
<!-- Nama Pengguna Field -->
|
||||
<div>
|
||||
<label for="username" class="block text-sm font-medium text-gray-700 mb-2">
|
||||
Nama Pengguna
|
||||
<label for="email" class="block text-sm font-medium text-gray-700 mb-2">
|
||||
Email
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
id="username"
|
||||
name="username"
|
||||
value="{{ old('username', 'admin.tomat') }}"
|
||||
placeholder="admin.tomat"
|
||||
type="email"
|
||||
id="email"
|
||||
name="email"
|
||||
value="{{ old('email') }}"
|
||||
placeholder="admin@gmail.com"
|
||||
class="input-field w-full px-4 py-3 border border-gray-300 rounded-lg text-gray-900 placeholder-gray-400 transition-all duration-200"
|
||||
required
|
||||
autocomplete="username"
|
||||
autocomplete="email"
|
||||
>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,10 @@
|
|||
<div class="hidden md:block">
|
||||
<div class="ml-10 flex items-baseline space-x-4">
|
||||
<a href="#" class="text-gray-900 hover:text-red-600 px-3 py-2 rounded-md text-sm font-medium transition-colors">Beranda</a>
|
||||
<a href="#" class="text-gray-500 hover:text-red-600 px-3 py-2 rounded-md text-sm font-medium transition-colors">Tentang kami</a>
|
||||
<a href="{{ route('about') }}"class="text-gray-500 hover:text-red-600 px-3 py-2 rounded-md text-sm font-medium transition-colors">Tentang kami</a>
|
||||
<a href="{{ route('login') }}" class="bg-red-600 hover:bg-red-700 text-white px-4 py-2 rounded-md text-sm font-medium transition-colors">
|
||||
<i class="fas fa-sign-in-alt mr-2"></i>Login
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="md:hidden">
|
||||
|
|
@ -57,9 +60,9 @@
|
|||
<a href="{{ route('upload.index') }}" class="bg-red-600 hover:bg-red-700 text-white font-semibold py-3 px-8 rounded-lg shadow-lg transform hover:scale-105 transition-all duration-200 inline-block text-center">
|
||||
📤 Unggah Gambar Tomat
|
||||
</a>
|
||||
<button class="bg-white hover:bg-gray-50 text-gray-700 font-semibold py-3 px-8 rounded-lg shadow-md border border-gray-200 transition-all duration-200">
|
||||
<a href="{{ route('about') }}" class="bg-white hover:bg-gray-50 text-gray-700 font-semibold py-3 px-8 rounded-lg shadow-md border border-gray-200 transition-all duration-200 inline-block text-center">
|
||||
Pelajari Lebih Lanjut
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="relative">
|
||||
|
|
|
|||
|
|
@ -9,14 +9,19 @@
|
|||
|
||||
// About page
|
||||
Route::get('/about', function () {
|
||||
return view('about');
|
||||
});
|
||||
return view('landing_page.about');
|
||||
})->name('about');
|
||||
|
||||
// Upload routes
|
||||
Route::get('/upload', [UploadController::class, 'index'])->name('upload.index');
|
||||
Route::post('/upload', [UploadController::class, 'store'])->name('upload.store');
|
||||
Route::get('/upload/result', [UploadController::class, 'result'])->name('upload.result');
|
||||
|
||||
// Login route (redirect to admin login)
|
||||
Route::get('/login', function () {
|
||||
return redirect()->route('admin.login');
|
||||
})->name('login');
|
||||
|
||||
// Admin login routes
|
||||
Route::get('/admin/login', function () {
|
||||
return view('login');
|
||||
|
|
@ -26,15 +31,41 @@
|
|||
|
||||
// Admin dashboard route
|
||||
Route::get('/admin/dashboard', function () {
|
||||
if (!session('admin_logged_in')) {
|
||||
return redirect()->route('admin.login')->with('error', 'Silakan login terlebih dahulu.');
|
||||
}
|
||||
return view('Admin.index');
|
||||
})->name('admin.dashboard');
|
||||
|
||||
// Manage admin route
|
||||
Route::get('/admin/manage-admin', function () {
|
||||
if (!session('admin_logged_in')) {
|
||||
return redirect()->route('admin.login')->with('error', 'Silakan login terlebih dahulu.');
|
||||
}
|
||||
return view('Admin.manage-admin');
|
||||
})->name('admin.manage-admin');
|
||||
|
||||
// Classification history route
|
||||
Route::get('/admin/classification-history', function () {
|
||||
if (!session('admin_logged_in')) {
|
||||
return redirect()->route('admin.login')->with('error', 'Silakan login terlebih dahulu.');
|
||||
}
|
||||
return view('Admin.classification-history');
|
||||
})->name('admin.classification-history');
|
||||
|
||||
// System statistics route
|
||||
Route::get('/admin/system-statistics', function () {
|
||||
if (!session('admin_logged_in')) {
|
||||
return redirect()->route('admin.login')->with('error', 'Silakan login terlebih dahulu.');
|
||||
}
|
||||
return view('Admin.system-statistics');
|
||||
})->name('admin.system-statistics');
|
||||
|
||||
|
||||
Route::get('/admin/logout', function () {
|
||||
return view('Admin.logout');
|
||||
// Clear admin session
|
||||
session()->forget(['admin_logged_in', 'admin_user_id', 'admin_name']);
|
||||
|
||||
// Redirect to login with success message
|
||||
return redirect()->route('admin.login')->with('success', 'Anda telah berhasil logout.');
|
||||
})->name('admin.logout');
|
||||
|
|
|
|||
Loading…
Reference in New Issue