From a79a804b68c6dc39b4c1dbb6a012cc80f51b02de Mon Sep 17 00:00:00 2001 From: MuzakkiABBAUF Date: Fri, 3 Oct 2025 10:41:35 +0700 Subject: [PATCH] fix fix --- .../Http/Controllers/DashboardController.php | 22 +- .../Http/Controllers/TemplateController.php | 6 +- .../views/admin/auth/login.blade.php | 321 ++++++------------ .../resources/views/admin/dashboard.blade.php | 2 +- .../views/admin/kategori/index.blade.php | 115 ++++--- .../views/admin/template/edit.blade.php | 67 ++++ .../views/admin/template/index.blade.php | 83 +++-- .../resources/views/layouts/app.blade.php | 112 ++---- backend-baru/routes/web.php | 38 ++- 9 files changed, 338 insertions(+), 428 deletions(-) diff --git a/backend-baru/app/Http/Controllers/DashboardController.php b/backend-baru/app/Http/Controllers/DashboardController.php index 7f61cd3..f81ed53 100644 --- a/backend-baru/app/Http/Controllers/DashboardController.php +++ b/backend-baru/app/Http/Controllers/DashboardController.php @@ -3,29 +3,13 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; -use App\Models\Kategori; -use App\Models\Template; -use App\Models\Pelanggan; -use Carbon\Carbon; class DashboardController extends Controller { public function index() { - $totalKategori = Kategori::count(); - $totalTemplate = Template::count(); - $totalPelanggan = Pelanggan::count(); - $today = Carbon::now()->translatedFormat('l, d F Y'); - - // ambil 5 pelanggan terbaru - $recentPelanggan = Pelanggan::latest()->paginate(5); - - return view('admin.dashboard', compact( - 'totalKategori', - 'totalTemplate', - 'totalPelanggan', - 'today', - 'recentPelanggan' - )); + // Karena jumlah kategori, template, dan pelanggan statis, + // maka kita tidak perlu query database di sini. + return view('admin.dashboard'); } } diff --git a/backend-baru/app/Http/Controllers/TemplateController.php b/backend-baru/app/Http/Controllers/TemplateController.php index bed3838..df39d3e 100644 --- a/backend-baru/app/Http/Controllers/TemplateController.php +++ b/backend-baru/app/Http/Controllers/TemplateController.php @@ -11,13 +11,13 @@ class TemplateController extends Controller public function index() { $templates = Template::with('kategori')->get(); - return view('admin.templates.index', compact('templates')); + return view('admin.template.index', compact('templates')); } // Form edit (untuk ubah harga / nama dsb) public function edit(Template $template) { - return view('admin.templates.edit', compact('template')); + return view('admin.template.edit', compact('template')); } // Update template (ubah harga / nama / paket) @@ -31,7 +31,7 @@ class TemplateController extends Controller $template->update($validated); - return redirect()->route('admin.templates.index') + return redirect()->route('admin.template.index') ->with('success', 'Template berhasil diperbarui!'); } } diff --git a/backend-baru/resources/views/admin/auth/login.blade.php b/backend-baru/resources/views/admin/auth/login.blade.php index d048d77..6e5a581 100644 --- a/backend-baru/resources/views/admin/auth/login.blade.php +++ b/backend-baru/resources/views/admin/auth/login.blade.php @@ -1,232 +1,109 @@ -@extends('layouts.app') + + -@section('title', 'Halaman Dasbor') + + + + Login Admin + + + + + +
+
+ +
- -
-
-
-
Kategori
-

{{ $totalKategori }}

-
-
- -
+

SELAMAT DATANG

+

Silakan masukkan email dan password anda.

+ + @if ($errors->any()) +
+ {{ $errors->first() }}
-
-
-
Template
-

{{ $totalTemplate }}

-
-
- -
+ @endif + +
+ @csrf +
+ +
-
-
-
Pelanggan
-

{{ $totalPelanggan }}

-
-
- -
+
+ +
-
- - -
-
-

Pelanggan Terbaru

- - - - - - - - - - - - - - - - @forelse($recentPelanggan as $index => $pelanggan) - - - - - - - - - - - - @empty - - - - @endforelse - -
NomorNamaTemplateKategoriEmailNo. TeleponHargaTanggal PemesananAksi
- {{ $recentPelanggan->firstItem() + $index }} - {{ $pelanggan->nama_pemesan }}{{ $pelanggan->nama_template }}{{ $pelanggan->kategori ?? '-' }}{{ $pelanggan->email }}{{ $pelanggan->no_tlpn ?? '-' }} - Rp {{ number_format($pelanggan->harga, 0, ',', '.') }} - - {{ \Carbon\Carbon::parse($pelanggan->created_at)->format('d M Y') }} - -
- - Detail - - -
-
- Belum ada data pelanggan. -
- - -
-
- {{-- Tombol Previous --}} - @if ($recentPelanggan->onFirstPage()) - Prev - @else - Prev - @endif - - @php - $total = $recentPelanggan->lastPage(); - $current = $recentPelanggan->currentPage(); - @endphp - - {{-- Selalu tampilkan halaman pertama --}} - @if ($current > 2) - 1 - @if ($current > 3) - ... - @endif - @endif - - {{-- Hanya tampilkan 3 halaman di tengah (current-1, current, current+1) --}} - @for ($i = max(1, $current - 1); $i <= min($total, $current + 1); $i++) - @if ($i == $current) - {{ $i }} - @else - {{ $i }} - @endif - @endfor - - {{-- Selalu tampilkan halaman terakhir --}} - @if ($current < $total - 1) - @if ($current < $total - 2) - ... - @endif - {{ $total }} - @endif - - {{-- Tombol Next --}} - @if ($recentPelanggan->hasMorePages()) - Next - @else - Next - @endif -
+
+
+ +
+ Lupa kata sandi
-
+ + +
+ - - @foreach ($recentPelanggan as $pelanggan) - - @endforeach - - - @endsection + diff --git a/backend-baru/resources/views/admin/dashboard.blade.php b/backend-baru/resources/views/admin/dashboard.blade.php index 21d2f29..3bc9a14 100644 --- a/backend-baru/resources/views/admin/dashboard.blade.php +++ b/backend-baru/resources/views/admin/dashboard.blade.php @@ -10,7 +10,7 @@
- 02 Okt 2025 + {{ \Carbon\Carbon::now()->translatedFormat('d M Y') }}
diff --git a/backend-baru/resources/views/admin/kategori/index.blade.php b/backend-baru/resources/views/admin/kategori/index.blade.php index c4fd68d..de0a23f 100644 --- a/backend-baru/resources/views/admin/kategori/index.blade.php +++ b/backend-baru/resources/views/admin/kategori/index.blade.php @@ -3,54 +3,79 @@ @section('title', 'Manajemen Kategori') @section('content') -
-

Daftar Kategori

- - + Tambah Kategori +
+
+

Daftar Kategori

+ + Tambah Kategori + +
+ @if(session('success')) -
{{ session('success') }}
+
+ {{ session('success') }} +
@endif - - - - - - - - - - - - @forelse($kategori as $index => $kat) - - - - - - - - @empty - - - - @endforelse - -
#NamaDeskripsiFotoAksi
{{ $index + 1 }}{{ $kat->nama }}{{ $kat->deskripsi }} - @if($kat->foto) - - @else - Tidak ada - @endif - - Edit -
- @csrf - @method('DELETE') - -
-
Belum ada kategori.
+ +
+ + + + + + + + + + + + @forelse($kategori as $index => $kat) + + + + + + + + @empty + + + + @endforelse + +
#NamaDeskripsiFotoAksi
{{ $index + 1 }}{{ $kat->nama }}{{ $kat->deskripsi ?? '-' }} + @if($kat->foto) +
+ +
+ @else + Tidak ada + @endif +
+
+ + Edit + +
+ @csrf + @method('DELETE') + +
+
+
+ Belum ada kategori. +
+
@endsection diff --git a/backend-baru/resources/views/admin/template/edit.blade.php b/backend-baru/resources/views/admin/template/edit.blade.php index e69de29..8780d4c 100644 --- a/backend-baru/resources/views/admin/template/edit.blade.php +++ b/backend-baru/resources/views/admin/template/edit.blade.php @@ -0,0 +1,67 @@ +@extends('layouts.app') + +@section('title', 'Edit Template') + +@section('content') +
+

Edit Template

+ + {{-- Alert sukses / error --}} + @if(session('success')) +
{{ session('success') }}
+ @endif + @if($errors->any()) +
+
    + @foreach($errors->all() as $err) +
  • {{ $err }}
  • + @endforeach +
+
+ @endif + +
+ @csrf + @method('PUT') + + {{-- Nama Template --}} +
+ + + @error('nama_template') +
{{ $message }}
+ @enderror +
+ + {{-- Harga --}} +
+ + + @error('harga') +
{{ $message }}
+ @enderror +
+ + {{-- Paket --}} +
+ + + @error('paket') +
{{ $message }}
+ @enderror +
+ + {{-- Tombol --}} + + Batal +
+
+@endsection diff --git a/backend-baru/resources/views/admin/template/index.blade.php b/backend-baru/resources/views/admin/template/index.blade.php index f6bfe88..bf59d20 100644 --- a/backend-baru/resources/views/admin/template/index.blade.php +++ b/backend-baru/resources/views/admin/template/index.blade.php @@ -3,37 +3,58 @@ @section('title', 'Manajemen Template') @section('content') -
-

Daftar Template

- + Tambah Template +
+
+

Daftar Template

+
- - - - - - - - - - - - @foreach($templates as $t) - - - - - - - - @endforeach - -
NamaKategoriPaketHargaAksi
{{ $t->nama_template }}{{ $t->kategori->nama ?? '-' }}{{ ucfirst($t->paket) }}Rp {{ number_format($t->harga,0,',','.') }} - Edit -
- @csrf @method('DELETE') - -
-
+ + @if(session('success')) +
+ {{ session('success') }} +
+ @endif + + +
+ + + + + + + + + + + + + @forelse($templates as $index => $t) + + + + + + + + + @empty + + + + @endforelse + +
#NamaKategoriPaketHargaAksi
{{ $index + 1 }}{{ $t->nama_template }}{{ $t->kategori->nama ?? '-' }}{{ ucfirst($t->paket) }}Rp {{ number_format($t->harga,0,',','.') }} + +
+ Belum ada template. +
+
@endsection diff --git a/backend-baru/resources/views/layouts/app.blade.php b/backend-baru/resources/views/layouts/app.blade.php index f485a73..70cd9d5 100644 --- a/backend-baru/resources/views/layouts/app.blade.php +++ b/backend-baru/resources/views/layouts/app.blade.php @@ -4,7 +4,7 @@ - Admin Panel + @yield('title', 'Admin Panel') + +
-

Dasbor

-
-

Selamat datang di panel admin. Ini adalah area konten utama.

-
+ @yield('content')
- - - - \ No newline at end of file + diff --git a/backend-baru/routes/web.php b/backend-baru/routes/web.php index 8d6f36e..502461c 100644 --- a/backend-baru/routes/web.php +++ b/backend-baru/routes/web.php @@ -3,25 +3,26 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\AdminAuthController; use App\Http\Controllers\DashboardController; +use App\Http\Controllers\KategoriController; +use App\Http\Controllers\TemplateController; +use Illuminate\Support\Facades\Auth; -/* -|-------------------------------------------------------------------------- -| Web Routes -|-------------------------------------------------------------------------- -| -| Here is where you can register web routes for your application. These -| routes are loaded by the RouteServiceProvider and all of them will -| be assigned to the "web" middleware group. Make something great! -| -*/ +// logout umum +Route::post('/logout', function () { + Auth::logout(); + request()->session()->invalidate(); + request()->session()->regenerateToken(); + return redirect()->route('admin.login'); +})->name('logout'); -// Redirect root "/" ke halaman login admin +// redirect root ke login admin Route::get('/', function () { return redirect()->route('admin.login'); }); -// Admin Auth +// Admin routes Route::prefix('admin')->name('admin.')->group(function () { + // Auth Route::middleware('guest:admin')->group(function () { Route::get('/login', [AdminAuthController::class, 'showLogin'])->name('login'); Route::post('/login', [AdminAuthController::class, 'login'])->name('login.post'); @@ -29,10 +30,17 @@ Route::prefix('admin')->name('admin.')->group(function () { Route::middleware('auth:admin')->group(function () { Route::get('/dashboard', function () { - return view('admin.dashboard'); -})->name('dashboard'); + return view('admin.dashboard'); + })->name('dashboard'); Route::post('/logout', [AdminAuthController::class, 'logout'])->name('logout'); + + // Resource routes + Route::resource('kategori', KategoriController::class); + + // Template routes (index, edit, update) + Route::get('/template', [TemplateController::class, 'index'])->name('template.index'); + Route::get('/template/{template}/edit', [TemplateController::class, 'edit'])->name('template.edit'); + Route::put('/template/{template}', [TemplateController::class, 'update'])->name('template.update'); }); }); -