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
|
// Validate the request
|
||||||
$validator = Validator::make($request->all(), [
|
$validator = Validator::make($request->all(), [
|
||||||
'username' => 'required|string|max:255',
|
'email' => 'required|email|max:255',
|
||||||
'password' => 'required|string|min:6',
|
'password' => 'required|string|min:6',
|
||||||
], [
|
], [
|
||||||
'username.required' => 'Nama pengguna harus diisi.',
|
'email.required' => 'Email harus diisi.',
|
||||||
'username.string' => 'Nama pengguna harus berupa string.',
|
'email.email' => 'Format email tidak valid.',
|
||||||
'username.max' => 'Nama pengguna maksimal 255 karakter.',
|
'email.max' => 'Email maksimal 255 karakter.',
|
||||||
'password.required' => 'Kata sandi harus diisi.',
|
'password.required' => 'Kata sandi harus diisi.',
|
||||||
'password.string' => 'Kata sandi harus berupa string.',
|
'password.string' => 'Kata sandi harus berupa string.',
|
||||||
'password.min' => 'Kata sandi minimal 6 karakter.',
|
'password.min' => 'Kata sandi minimal 6 karakter.',
|
||||||
|
|
@ -210,22 +210,24 @@ public function adminLogin(Request $request)
|
||||||
->withInput();
|
->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple authentication (replace with proper authentication in production)
|
// Database authentication
|
||||||
$username = $request->input('username');
|
$email = $request->input('email');
|
||||||
$password = $request->input('password');
|
$password = $request->input('password');
|
||||||
|
|
||||||
// Demo credentials - replace with proper authentication
|
// Find user by email
|
||||||
if ($username === 'admin.tomat' && $password === 'admin123') {
|
$user = \DB::table('users')->where('email', $email)->first();
|
||||||
// Store session
|
|
||||||
session(['admin_logged_in' => true, 'admin_username' => $username]);
|
|
||||||
|
|
||||||
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
|
// Failed login
|
||||||
return redirect()
|
return redirect()
|
||||||
->route('admin.login')
|
->route('admin.login')
|
||||||
->withErrors(['login' => 'Nama pengguna atau kata sandi salah.'])
|
->withErrors(['login' => 'Email atau kata sandi salah.'])
|
||||||
->withInput($request->except('password'));
|
->withInput($request->except('password'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,6 @@ class DatabaseSeeder extends Seeder
|
||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
// User::factory(10)->create();
|
$this->call(AdminSeeder::class);
|
||||||
|
|
||||||
User::factory()->create([
|
|
||||||
'name' => 'Test User',
|
|
||||||
'email' => 'test@example.com',
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,22 @@ class="sidebar-item flex items-center space-x-3 px-4 py-3 rounded-lg text-gray-7
|
||||||
</a>
|
</a>
|
||||||
</nav>
|
</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 -->
|
<!-- Logout Section -->
|
||||||
<div class="p-4 border-t border-gray-200">
|
<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">
|
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>
|
<i class="fas fa-sign-out-alt w-5"></i>
|
||||||
<span>Logout</span>
|
<span>Logout</span>
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,11 @@
|
||||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
<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" />
|
<link href="https://fonts.bunny.net/css?family=inter:300,400,500,600,700&display=swap" rel="stylesheet" />
|
||||||
|
|
||||||
<!-- Styles -->
|
<!-- Tailwind CSS -->
|
||||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
<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>
|
</head>
|
||||||
<body class="bg-white">
|
<body class="bg-white">
|
||||||
<!-- Navbar -->
|
<!-- Navbar -->
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,11 @@
|
||||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
<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" />
|
<link href="https://fonts.bunny.net/css?family=inter:300,400,500,600,700&display=swap" rel="stylesheet" />
|
||||||
|
|
||||||
<!-- Styles -->
|
<!-- Tailwind CSS -->
|
||||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
<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>
|
<style>
|
||||||
/* Custom styles for better focus states */
|
/* Custom styles for better focus states */
|
||||||
.input-field:focus {
|
.input-field:focus {
|
||||||
|
|
@ -73,18 +76,18 @@
|
||||||
|
|
||||||
<!-- Nama Pengguna Field -->
|
<!-- Nama Pengguna Field -->
|
||||||
<div>
|
<div>
|
||||||
<label for="username" class="block text-sm font-medium text-gray-700 mb-2">
|
<label for="email" class="block text-sm font-medium text-gray-700 mb-2">
|
||||||
Nama Pengguna
|
Email
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="email"
|
||||||
id="username"
|
id="email"
|
||||||
name="username"
|
name="email"
|
||||||
value="{{ old('username', 'admin.tomat') }}"
|
value="{{ old('email') }}"
|
||||||
placeholder="admin.tomat"
|
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"
|
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
|
required
|
||||||
autocomplete="username"
|
autocomplete="email"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,10 @@
|
||||||
<div class="hidden md:block">
|
<div class="hidden md:block">
|
||||||
<div class="ml-10 flex items-baseline space-x-4">
|
<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-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>
|
</div>
|
||||||
<div class="md:hidden">
|
<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">
|
<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
|
📤 Unggah Gambar Tomat
|
||||||
</a>
|
</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
|
Pelajari Lebih Lanjut
|
||||||
</button>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,19 @@
|
||||||
|
|
||||||
// About page
|
// About page
|
||||||
Route::get('/about', function () {
|
Route::get('/about', function () {
|
||||||
return view('about');
|
return view('landing_page.about');
|
||||||
});
|
})->name('about');
|
||||||
|
|
||||||
// Upload routes
|
// Upload routes
|
||||||
Route::get('/upload', [UploadController::class, 'index'])->name('upload.index');
|
Route::get('/upload', [UploadController::class, 'index'])->name('upload.index');
|
||||||
Route::post('/upload', [UploadController::class, 'store'])->name('upload.store');
|
Route::post('/upload', [UploadController::class, 'store'])->name('upload.store');
|
||||||
Route::get('/upload/result', [UploadController::class, 'result'])->name('upload.result');
|
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
|
// Admin login routes
|
||||||
Route::get('/admin/login', function () {
|
Route::get('/admin/login', function () {
|
||||||
return view('login');
|
return view('login');
|
||||||
|
|
@ -26,15 +31,41 @@
|
||||||
|
|
||||||
// Admin dashboard route
|
// Admin dashboard route
|
||||||
Route::get('/admin/dashboard', function () {
|
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');
|
return view('Admin.index');
|
||||||
})->name('admin.dashboard');
|
})->name('admin.dashboard');
|
||||||
|
|
||||||
// Manage admin route
|
// Manage admin route
|
||||||
Route::get('/admin/manage-admin', function () {
|
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');
|
return view('Admin.manage-admin');
|
||||||
})->name('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 () {
|
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');
|
})->name('admin.logout');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue