From 44dfdec0b029ead1ebaaf55a631a386498f685e6 Mon Sep 17 00:00:00 2001 From: ariefabbauftech-ai Date: Mon, 8 Sep 2025 15:55:58 +0700 Subject: [PATCH] [Ubah All] --- .../Controllers/Api/KategoriApiController.php | 21 ++++ .../Controllers/Api/KhitanApiController.php | 48 +++++++++ .../Api/PernikahanApiController.php | 49 +++++++++ .../Controllers/Api/TemplateApiController.php | 21 ++++ .../Controllers/Api/TemplateController.php | 101 ------------------ .../Api/UlangTahunApiController.php | 51 +++++++++ .../app/Http/Controllers/FiturController.php | 49 +++++---- .../Http/Controllers/KategoriController.php | 73 +++++-------- .../Http/Controllers/PelangganController.php | 29 +++++ .../Http/Controllers/TemplateController.php | 63 +++++++++++ backend/app/Models/Fitur.php | 12 +-- backend/app/Models/Kategori.php | 5 +- backend/app/Models/Khitan.php | 19 ++++ backend/app/Models/Pelanggan.php | 25 +++++ backend/app/Models/PelangganDetail.php | 22 ++++ backend/app/Models/Pernikahan.php | 18 ++++ backend/app/Models/Template.php | 39 ++++--- backend/app/Models/UlangTahun.php | 19 ++++ ...25_09_01_045812_create_kategoris_table.php | 4 +- .../2025_09_02_042051_create_fiturs_table.php | 12 +-- ...25_09_03_042108_create_templates_table.php | 26 ++--- ...5_09_08_085234_create_pelanggans_table.php | 26 +++++ ..._085238_create_pelanggan_details_table.php | 24 +++++ ...08_085321_create_pernikahans_table.php.php | 33 ++++++ ...8_085336_create_ulang_tahuns_table.php.php | 33 ++++++ ..._09_08_085416_create_khitans_table.php.php | 32 ++++++ backend/routes/api.php | 29 +++-- backend/routes/web.php | 36 ++++--- 28 files changed, 664 insertions(+), 255 deletions(-) create mode 100644 backend/app/Http/Controllers/Api/KategoriApiController.php create mode 100644 backend/app/Http/Controllers/Api/KhitanApiController.php create mode 100644 backend/app/Http/Controllers/Api/PernikahanApiController.php create mode 100644 backend/app/Http/Controllers/Api/TemplateApiController.php delete mode 100644 backend/app/Http/Controllers/Api/TemplateController.php create mode 100644 backend/app/Http/Controllers/Api/UlangTahunApiController.php create mode 100644 backend/app/Http/Controllers/PelangganController.php create mode 100644 backend/app/Http/Controllers/TemplateController.php create mode 100644 backend/app/Models/Khitan.php create mode 100644 backend/app/Models/Pelanggan.php create mode 100644 backend/app/Models/PelangganDetail.php create mode 100644 backend/app/Models/Pernikahan.php create mode 100644 backend/app/Models/UlangTahun.php create mode 100644 backend/database/migrations/2025_09_08_085234_create_pelanggans_table.php create mode 100644 backend/database/migrations/2025_09_08_085238_create_pelanggan_details_table.php create mode 100644 backend/database/migrations/2025_09_08_085321_create_pernikahans_table.php.php create mode 100644 backend/database/migrations/2025_09_08_085336_create_ulang_tahuns_table.php.php create mode 100644 backend/database/migrations/2025_09_08_085416_create_khitans_table.php.php diff --git a/backend/app/Http/Controllers/Api/KategoriApiController.php b/backend/app/Http/Controllers/Api/KategoriApiController.php new file mode 100644 index 0000000..275b92d --- /dev/null +++ b/backend/app/Http/Controllers/Api/KategoriApiController.php @@ -0,0 +1,21 @@ +json(Kategori::all()); + } + + // Ambil detail satu kategori + public function show(Kategori $kategori) + { + return response()->json($kategori); + } +} diff --git a/backend/app/Http/Controllers/Api/KhitanApiController.php b/backend/app/Http/Controllers/Api/KhitanApiController.php new file mode 100644 index 0000000..c617ea3 --- /dev/null +++ b/backend/app/Http/Controllers/Api/KhitanApiController.php @@ -0,0 +1,48 @@ +validate([ + 'nama_pemesan' => 'required|string|max:255', + 'no_hp' => 'required|string|max:20', + 'email' => 'required|email', + 'nama_anak' => 'required|string|max:255', + 'nama_orangtua' => 'required|string|max:255', + 'alamat' => 'required|string', + 'tanggal_acara' => 'required|date', + 'link_musik' => 'nullable|string', + 'kata_pengucapan' => 'nullable|string', + 'galeri' => 'nullable|string', + 'template_id' => 'required|exists:templates,id', + ]); + + $pelanggan = Pelanggan::create([ + 'nama_pemesan' => $data['nama_pemesan'], + 'nama_template' => 'Template Khitan', + 'kategori' => 'khitan', + 'email' => $data['email'], + 'no_tlpn' => $data['no_hp'], + 'harga' => 0, + ]); + + PelangganDetail::create([ + 'pelanggan_id' => $pelanggan->id, + 'detail_form' => $data, + ]); + + return response()->json([ + 'success' => true, + 'message' => 'Form khitan berhasil dikirim', + 'data' => $pelanggan->load('details') + ], 201); + } +} diff --git a/backend/app/Http/Controllers/Api/PernikahanApiController.php b/backend/app/Http/Controllers/Api/PernikahanApiController.php new file mode 100644 index 0000000..1408ae3 --- /dev/null +++ b/backend/app/Http/Controllers/Api/PernikahanApiController.php @@ -0,0 +1,49 @@ +validate([ + 'nama_pemesan' => 'required|string|max:255', + 'no_hp' => 'required|string|max:20', + 'email' => 'required|email', + 'nama_pria' => 'required|string|max:255', + 'nama_wanita' => 'required|string|max:255', + 'alamat' => 'required|string', + 'tanggal_acara' => 'required|date', + 'link_undangan' => 'nullable|string', + 'kata_pengucapan' => 'nullable|string', + 'galeri' => 'nullable|string', + 'link_musik' => 'nullable|string', + 'template_id' => 'required|exists:templates,id', + ]); + + $pelanggan = Pelanggan::create([ + 'nama_pemesan' => $data['nama_pemesan'], + 'nama_template' => 'Template Pernikahan', + 'kategori' => 'pernikahan', + 'email' => $data['email'], + 'no_tlpn' => $data['no_hp'], + 'harga' => 0, + ]); + + PelangganDetail::create([ + 'pelanggan_id' => $pelanggan->id, + 'detail_form' => $data, + ]); + + return response()->json([ + 'success' => true, + 'message' => 'Form pernikahan berhasil dikirim', + 'data' => $pelanggan->load('details') + ], 201); + } +} diff --git a/backend/app/Http/Controllers/Api/TemplateApiController.php b/backend/app/Http/Controllers/Api/TemplateApiController.php new file mode 100644 index 0000000..b6f631f --- /dev/null +++ b/backend/app/Http/Controllers/Api/TemplateApiController.php @@ -0,0 +1,21 @@ +json(Template::with(['kategori','fitur'])->get()); + } + + // User bisa lihat detail 1 template + public function show(Template $template) + { + return response()->json($template->load(['kategori','fitur'])); + } +} diff --git a/backend/app/Http/Controllers/Api/TemplateController.php b/backend/app/Http/Controllers/Api/TemplateController.php deleted file mode 100644 index ea29625..0000000 --- a/backend/app/Http/Controllers/Api/TemplateController.php +++ /dev/null @@ -1,101 +0,0 @@ -get(); - return response()->json($templates); - } - - /** - * Menyimpan template baru. - */ - public function store(Request $request) - { - try { - $validated = $request->validate([ - 'kategori_id' => 'required|exists:kategoris,id', - 'nama_template' => 'required|string|max:255', - 'fitur' => 'nullable|string', - 'foto' => 'nullable|string', - ]); - - $template = Template::create($validated); - return response()->json($template, 201); - } catch (ValidationException $e) { - return response()->json([ - 'message' => 'Validation failed', - 'errors' => $e->errors() - ], 422); - } - } - - /** - * Mengambil detail satu template berdasarkan ID. - */ - public function show($id) - { - $template = Template::with('kategori')->find($id); - - if (!$template) { - return response()->json(['message' => 'Template not found'], 404); - } - - return response()->json($template); - } - - /** - * Memperbarui template yang sudah ada. - */ - public function update(Request $request, $id) - { - $template = Template::find($id); - - if (!$template) { - return response()->json(['message' => 'Template not found'], 404); - } - - try { - $validated = $request->validate([ - 'kategori_id' => 'required|exists:kategoris,id', - 'nama_template' => 'required|string|max:255', - 'fitur' => 'nullable|string', - 'foto' => 'nullable|string', - ]); - - $template->update($validated); - return response()->json($template); - } catch (ValidationException $e) { - return response()->json([ - 'message' => 'Validation failed', - 'errors' => $e->errors() - ], 422); - } - } - - /** - * Menghapus template. - */ - public function destroy($id) - { - $template = Template::find($id); - - if (!$template) { - return response()->json(['message' => 'Template not found'], 404); - } - - $template->delete(); - return response()->json(null, 204); - } -} \ No newline at end of file diff --git a/backend/app/Http/Controllers/Api/UlangTahunApiController.php b/backend/app/Http/Controllers/Api/UlangTahunApiController.php new file mode 100644 index 0000000..b175845 --- /dev/null +++ b/backend/app/Http/Controllers/Api/UlangTahunApiController.php @@ -0,0 +1,51 @@ +validate([ + 'nama_pemesan' => 'required|string|max:255', + 'no_hp' => 'required|string|max:20', + 'email' => 'required|email', + 'nama_panjang' => 'required|string|max:255', + 'nama_panggilan' => 'required|string|max:255', + 'ulang_tahun_ke' => 'required|integer', + 'anak_ke' => 'required|integer', + 'nama_orangtua' => 'required|string|max:255', + 'alamat' => 'required|string', + 'tanggal_acara' => 'required|date', + 'link_musik' => 'nullable|string', + 'kata_pengucapan' => 'nullable|string', + 'galeri' => 'nullable|string', + 'template_id' => 'required|exists:templates,id', + ]); + + $pelanggan = Pelanggan::create([ + 'nama_pemesan' => $data['nama_pemesan'], + 'nama_template' => 'Template Ulang Tahun', + 'kategori' => 'ulang_tahun', + 'email' => $data['email'], + 'no_tlpn' => $data['no_hp'], + 'harga' => 0, + ]); + + PelangganDetail::create([ + 'pelanggan_id' => $pelanggan->id, + 'detail_form' => $data, + ]); + + return response()->json([ + 'success' => true, + 'message' => 'Form ulang tahun berhasil dikirim', + 'data' => $pelanggan->load('details') + ], 201); + } +} diff --git a/backend/app/Http/Controllers/FiturController.php b/backend/app/Http/Controllers/FiturController.php index c4fe253..aef9bba 100644 --- a/backend/app/Http/Controllers/FiturController.php +++ b/backend/app/Http/Controllers/FiturController.php @@ -2,53 +2,60 @@ namespace App\Http\Controllers; +use App\Http\Controllers\Controller; use App\Models\Fitur; use Illuminate\Http\Request; class FiturController extends Controller { - // Menampilkan semua fitur + // Tampilkan semua fitur (halaman admin) public function index() { $fiturs = Fitur::all(); - return view('admin.fitur.index', compact('fiturs')); + return view('fiturs.index', compact('fiturs')); } - // Menambah fitur baru + // Form tambah fitur + public function create() + { + return view('fiturs.create'); + } + + // Simpan fitur baru public function store(Request $request) { - $request->validate([ - 'nama_fitur' => 'required|string|max:255', + $data = $request->validate([ + 'deskripsi' => 'required|string', ]); - Fitur::create([ - 'nama_fitur' => $request->nama_fitur, - ]); + Fitur::create($data); - return redirect()->route('admin.fitur.index')->with('success', 'Fitur berhasil ditambahkan'); + return redirect()->route('fiturs.index')->with('success', 'Fitur berhasil ditambahkan!'); } - // Edit / update fitur - public function update(Request $request, $id) + // Form edit fitur + public function edit(Fitur $fitur) { - $request->validate([ - 'nama_fitur' => 'required|string|max:255', + return view('fiturs.edit', compact('fitur')); + } + + // Update fitur + public function update(Request $request, Fitur $fitur) + { + $data = $request->validate([ + 'deskripsi' => 'required|string', ]); - $fitur = Fitur::findOrFail($id); - $fitur->update([ - 'nama_fitur' => $request->nama_fitur, - ]); + $fitur->update($data); - return redirect()->route('admin.fitur.index')->with('success', 'Fitur berhasil diperbarui'); + return redirect()->route('fiturs.index')->with('success', 'Fitur berhasil diperbarui!'); } // Hapus fitur - public function destroy($id) + public function destroy(Fitur $fitur) { - $fitur = Fitur::findOrFail($id); $fitur->delete(); - return redirect()->route('admin.fitur.index')->with('success', 'Fitur berhasil dihapus'); + return redirect()->route('fiturs.index')->with('success', 'Fitur berhasil dihapus!'); } } diff --git a/backend/app/Http/Controllers/KategoriController.php b/backend/app/Http/Controllers/KategoriController.php index bc2bbba..f2c2c61 100644 --- a/backend/app/Http/Controllers/KategoriController.php +++ b/backend/app/Http/Controllers/KategoriController.php @@ -2,78 +2,55 @@ namespace App\Http\Controllers; +use App\Http\Controllers\Controller; use App\Models\Kategori; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Storage; class KategoriController extends Controller { - // Menampilkan semua kategori di halaman admin public function index() { - $kategori = Kategori::all(); - return view('admin.kategori.index', compact('kategori')); + $kategoris = Kategori::all(); + return view('kategoris.index', compact('kategoris')); } - // Menampilkan detail kategori (kalau dipakai di API) - public function show(Kategori $kategori) + public function create() { - return response()->json($kategori, 200); + return view('kategoris.create'); } - // Simpan kategori baru public function store(Request $request) { - $request->validate([ - 'nama' => 'required|string|max:255', - 'deskripsi' => 'nullable|string', - 'foto' => 'nullable|image|mimes:jpeg,png,jpg,gif|max:5120' - ]); - - $data = $request->all(); - if ($request->hasFile('foto')) { - $data['foto'] = $request->file('foto')->store('kategori', 'public'); - } - - Kategori::create($data); - - // Jika request berasal dari form admin → redirect - return redirect()->route('admin.kategori.index') - ->with('success', 'Kategori berhasil ditambahkan!'); - } - - // Update kategori - public function update(Request $request, Kategori $kategori) - { - $request->validate([ + $data = $request->validate([ 'nama' => 'required|string|max:255', 'deskripsi' => 'nullable|string', - 'foto' => 'nullable|image|mimes:jpg,jpeg,png|max:5120' + 'foto' => 'nullable|string', ]); - $data = $request->all(); - if ($request->hasFile('foto')) { - if ($kategori->foto) { - Storage::disk('public')->delete($kategori->foto); - } - $data['foto'] = $request->file('foto')->store('kategori', 'public'); - } + Kategori::create($data); + return redirect()->route('kategoris.index')->with('success', 'Kategori berhasil ditambahkan!'); + } + + public function edit(Kategori $kategori) + { + return view('kategoris.edit', compact('kategori')); + } + + public function update(Request $request, Kategori $kategori) + { + $data = $request->validate([ + 'nama' => 'required|string|max:255', + 'deskripsi' => 'nullable|string', + 'foto' => 'nullable|string', + ]); $kategori->update($data); - - return redirect()->route('admin.kategori.index') - ->with('success', 'Kategori berhasil diperbarui!'); + return redirect()->route('kategoris.index')->with('success', 'Kategori berhasil diperbarui!'); } - // Hapus kategori public function destroy(Kategori $kategori) { - if ($kategori->foto) { - Storage::disk('public')->delete($kategori->foto); - } $kategori->delete(); - - return redirect()->route('admin.kategori.index') - ->with('success', 'Kategori berhasil dihapus!'); + return redirect()->route('kategoris.index')->with('success', 'Kategori berhasil dihapus!'); } } diff --git a/backend/app/Http/Controllers/PelangganController.php b/backend/app/Http/Controllers/PelangganController.php new file mode 100644 index 0000000..a5f05f7 --- /dev/null +++ b/backend/app/Http/Controllers/PelangganController.php @@ -0,0 +1,29 @@ +get(); + return view('pelanggans.index', compact('pelanggans')); + } + + // Detail pelanggan + public function show(Pelanggan $pelanggan) + { + return view('pelanggans.show', compact('pelanggan')); + } + + // Hapus pelanggan + public function destroy(Pelanggan $pelanggan) + { + $pelanggan->delete(); + return redirect()->route('pelanggans.index')->with('success', 'Pelanggan berhasil dihapus!'); + } +} diff --git a/backend/app/Http/Controllers/TemplateController.php b/backend/app/Http/Controllers/TemplateController.php new file mode 100644 index 0000000..9c657cb --- /dev/null +++ b/backend/app/Http/Controllers/TemplateController.php @@ -0,0 +1,63 @@ +get(); + return view('templates.index', compact('templates')); + } + + public function create() + { + $kategoris = Kategori::all(); + $fiturs = Fitur::all(); + return view('templates.create', compact('kategoris', 'fiturs')); + } + + public function store(Request $request) + { + $data = $request->validate([ + 'nama_template' => 'required|string|max:255', + 'kategori_id' => 'required|exists:kategoris,id', + 'fitur_id' => 'required|exists:fiturs,id', + 'foto' => 'nullable|string', + ]); + + Template::create($data); + return redirect()->route('templates.index')->with('success', 'Template berhasil ditambahkan!'); + } + + public function edit(Template $template) + { + $kategoris = Kategori::all(); + $fiturs = Fitur::all(); + return view('templates.edit', compact('template','kategoris','fiturs')); + } + + public function update(Request $request, Template $template) + { + $data = $request->validate([ + 'nama_template' => 'required|string|max:255', + 'kategori_id' => 'required|exists:kategoris,id', + 'fitur_id' => 'required|exists:fiturs,id', + 'foto' => 'nullable|string', + ]); + + $template->update($data); + return redirect()->route('templates.index')->with('success', 'Template berhasil diperbarui!'); + } + + public function destroy(Template $template) + { + $template->delete(); + return redirect()->route('templates.index')->with('success', 'Template berhasil dihapus!'); + } +} diff --git a/backend/app/Models/Fitur.php b/backend/app/Models/Fitur.php index aa49d07..3e6dea1 100644 --- a/backend/app/Models/Fitur.php +++ b/backend/app/Models/Fitur.php @@ -1,15 +1,15 @@ hasMany(Template::class); + } } diff --git a/backend/app/Models/Kategori.php b/backend/app/Models/Kategori.php index 8787927..ebe5d15 100644 --- a/backend/app/Models/Kategori.php +++ b/backend/app/Models/Kategori.php @@ -1,14 +1,11 @@ belongsTo(Template::class); + } +} diff --git a/backend/app/Models/Pelanggan.php b/backend/app/Models/Pelanggan.php new file mode 100644 index 0000000..8286068 --- /dev/null +++ b/backend/app/Models/Pelanggan.php @@ -0,0 +1,25 @@ +hasOne(PelangganDetail::class); + } +} diff --git a/backend/app/Models/PelangganDetail.php b/backend/app/Models/PelangganDetail.php new file mode 100644 index 0000000..92eb652 --- /dev/null +++ b/backend/app/Models/PelangganDetail.php @@ -0,0 +1,22 @@ + 'array', + ]; + + public function pelanggan() + { + return $this->belongsTo(Pelanggan::class); + } +} diff --git a/backend/app/Models/Pernikahan.php b/backend/app/Models/Pernikahan.php new file mode 100644 index 0000000..d8fc1c0 --- /dev/null +++ b/backend/app/Models/Pernikahan.php @@ -0,0 +1,18 @@ +belongsTo(Template::class); + } +} diff --git a/backend/app/Models/Template.php b/backend/app/Models/Template.php index f5e0514..e1de704 100644 --- a/backend/app/Models/Template.php +++ b/backend/app/Models/Template.php @@ -1,31 +1,30 @@ belongsTo(Kategori::class, 'kategori_id'); + public function kategori() { + return $this->belongsTo(Kategori::class); } - public function pemesanan() - { - return $this->hasMany(Pemesanan::class, 'id_template', 'id_template'); + public function fitur() { + return $this->belongsTo(Fitur::class); } -} \ No newline at end of file + + public function pernikahan() { + return $this->hasOne(Pernikahan::class); + } + + public function ulangTahun() { + return $this->hasOne(UlangTahun::class); + } + + public function khitan() { + return $this->hasOne(Khitan::class); + } +} diff --git a/backend/app/Models/UlangTahun.php b/backend/app/Models/UlangTahun.php new file mode 100644 index 0000000..0a0a3d4 --- /dev/null +++ b/backend/app/Models/UlangTahun.php @@ -0,0 +1,19 @@ +belongsTo(Template::class); + } +} diff --git a/backend/database/migrations/2025_09_01_045812_create_kategoris_table.php b/backend/database/migrations/2025_09_01_045812_create_kategoris_table.php index 3767952..2b98ef2 100644 --- a/backend/database/migrations/2025_09_01_045812_create_kategoris_table.php +++ b/backend/database/migrations/2025_09_01_045812_create_kategoris_table.php @@ -1,6 +1,6 @@ -id(); - $table->string('nama_fitur'); + $table->text('deskripsi'); $table->timestamps(); }); } - public function down(): void - { + public function down(): void { Schema::dropIfExists('fiturs'); } }; diff --git a/backend/database/migrations/2025_09_03_042108_create_templates_table.php b/backend/database/migrations/2025_09_03_042108_create_templates_table.php index d0e7a44..34594c7 100644 --- a/backend/database/migrations/2025_09_03_042108_create_templates_table.php +++ b/backend/database/migrations/2025_09_03_042108_create_templates_table.php @@ -1,34 +1,24 @@ id('id_template'); // Primary Key - $table->unsignedBigInteger('kategori_id'); // Foreign Key ke kategori + $table->id(); $table->string('nama_template'); - $table->text('fitur')->nullable(); + $table->foreignId('kategori_id')->constrained()->cascadeOnDelete(); + $table->foreignId('fitur_id')->constrained()->cascadeOnDelete(); $table->string('foto')->nullable(); $table->timestamps(); - - // Relasi ke tabel kategori - $table->foreign('kategori_id')->references('id')->on('kategoris')->onDelete('cascade'); }); } - /** - * Reverse the migrations. - */ - public function down(): void - { + public function down(): void { Schema::dropIfExists('templates'); } }; + diff --git a/backend/database/migrations/2025_09_08_085234_create_pelanggans_table.php b/backend/database/migrations/2025_09_08_085234_create_pelanggans_table.php new file mode 100644 index 0000000..cb826b2 --- /dev/null +++ b/backend/database/migrations/2025_09_08_085234_create_pelanggans_table.php @@ -0,0 +1,26 @@ +id(); + $table->string('nama_pemesan'); + $table->string('nama_template'); + $table->string('kategori'); // pernikahan / ulang_tahun / khitan + $table->string('email'); + $table->string('no_tlpn'); + $table->decimal('harga', 15, 2)->nullable(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('pelanggans'); + } +}; diff --git a/backend/database/migrations/2025_09_08_085238_create_pelanggan_details_table.php b/backend/database/migrations/2025_09_08_085238_create_pelanggan_details_table.php new file mode 100644 index 0000000..f8dbc81 --- /dev/null +++ b/backend/database/migrations/2025_09_08_085238_create_pelanggan_details_table.php @@ -0,0 +1,24 @@ +id(); + $table->unsignedBigInteger('pelanggan_id'); + $table->json('detail_form'); // data sesuai kategori + $table->timestamps(); + + $table->foreign('pelanggan_id')->references('id')->on('pelanggans')->onDelete('cascade'); + }); + } + + public function down(): void + { + Schema::dropIfExists('pelanggan_details'); + } +}; diff --git a/backend/database/migrations/2025_09_08_085321_create_pernikahans_table.php.php b/backend/database/migrations/2025_09_08_085321_create_pernikahans_table.php.php new file mode 100644 index 0000000..2219c01 --- /dev/null +++ b/backend/database/migrations/2025_09_08_085321_create_pernikahans_table.php.php @@ -0,0 +1,33 @@ +id(); + $table->foreignId('template_id')->constrained()->cascadeOnDelete(); + $table->string('nama_pemesan'); + $table->string('no_hp'); + $table->string('email'); + $table->string('nama_pria'); + $table->string('nama_wanita'); + $table->string('alamat'); + $table->date('tanggal_acara'); + $table->string('link_undangan')->nullable(); + $table->text('kata_pengucapan')->nullable(); + $table->string('galeri')->nullable(); + $table->string('link_musik')->nullable(); + $table->timestamps(); + }); + } + + public function down(): void { + Schema::dropIfExists('pernikahans'); + } +}; + + diff --git a/backend/database/migrations/2025_09_08_085336_create_ulang_tahuns_table.php.php b/backend/database/migrations/2025_09_08_085336_create_ulang_tahuns_table.php.php new file mode 100644 index 0000000..93ca496 --- /dev/null +++ b/backend/database/migrations/2025_09_08_085336_create_ulang_tahuns_table.php.php @@ -0,0 +1,33 @@ +id(); + $table->foreignId('template_id')->constrained()->cascadeOnDelete(); + $table->string('nama_pemesan'); + $table->string('no_hp'); + $table->string('email'); + $table->string('nama_panjang'); + $table->string('nama_panggilan'); + $table->integer('ulang_tahun_ke'); + $table->integer('anak_ke'); + $table->string('nama_orangtua'); + $table->string('alamat'); + $table->date('tanggal_acara'); + $table->string('link_musik')->nullable(); + $table->text('kata_pengucapan')->nullable(); + $table->string('galeri')->nullable(); + $table->timestamps(); + }); + } + + public function down(): void { + Schema::dropIfExists('ulang_tahuns'); + } +}; diff --git a/backend/database/migrations/2025_09_08_085416_create_khitans_table.php.php b/backend/database/migrations/2025_09_08_085416_create_khitans_table.php.php new file mode 100644 index 0000000..8dc7109 --- /dev/null +++ b/backend/database/migrations/2025_09_08_085416_create_khitans_table.php.php @@ -0,0 +1,32 @@ +id(); + $table->foreignId('template_id')->constrained()->cascadeOnDelete(); + $table->string('nama_pemesan'); + $table->string('no_hp'); + $table->string('email'); + $table->string('nama_panjang'); + $table->string('nama_pendek'); + $table->string('nama_orangtua'); + $table->string('alamat'); + $table->date('tanggal_acara'); + $table->string('link_musik')->nullable(); + $table->string('galeri')->nullable(); + $table->text('kata_pengucapan')->nullable(); + $table->timestamps(); + }); + } + + public function down(): void { + Schema::dropIfExists('khitans'); + } +}; + diff --git a/backend/routes/api.php b/backend/routes/api.php index d9a8f4b..05c89fe 100644 --- a/backend/routes/api.php +++ b/backend/routes/api.php @@ -4,17 +4,24 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; use App\Http\Controllers\Api\ReviewController; use App\Http\Controllers\Api\TemplateController; +use App\Http\Controllers\Api\KategoriApiController; +use App\Http\Controllers\Api\PernikahanApiController; +use App\Http\Controllers\Api\UlangTahunApiController; +use App\Http\Controllers\Api\KhitanApiController; -/* -|-------------------------------------------------------------------------- -| API Routes -|-------------------------------------------------------------------------- -| -| Here is where you can register API routes for your application. These -| routes are loaded by the RouteServiceProvider and all of them will -| be assigned to the "api" middleware group. Make something great! -| -*/ +// Form API (user) +Route::post('form/pernikahan', [PernikahanApiController::class, 'store']); +Route::post('form/ulang-tahun', [UlangTahunApiController::class, 'store']); +Route::post('form/khitan', [KhitanApiController::class, 'store']); +// API Kategori hanya read-only +Route::get('kategoris', [KategoriApiController::class, 'index']); +Route::get('kategoris/{kategori}', [KategoriApiController::class, 'show']); + +// API Reviews Route::apiResource('reviews', ReviewController::class); -Route::apiResource('templates', TemplateController::class); + +// API Templates +Route::get('templates', [TemplateApiController::class, 'index']); +Route::get('templates/{template}', [TemplateApiController::class, 'show']); + diff --git a/backend/routes/web.php b/backend/routes/web.php index 3c73d58..4f631f0 100644 --- a/backend/routes/web.php +++ b/backend/routes/web.php @@ -2,9 +2,12 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\AdminAuthController; +use App\Http\Controllers\KategoriController; +use App\Http\Controllers\FiturController; +use App\Http\Controllers\TemplateController; +use App\Http\Controllers\PelangganController; - - +//Login Route::get('/', function () { return redirect()->route('admin.login'); }); @@ -23,14 +26,21 @@ Route::prefix('admin')->name('admin.')->group(function () { }); }); -use App\Http\Controllers\KategoriController; +//Kategori +Route::resource('kategoris', KategoriController::class)->middleware('auth'); + +// Route Admin Fitur +Route::resource('fiturs', FiturController::class)->middleware('auth'); + +// Route Admin Template +Route::resource('templates', TemplateController::class)->middleware('auth'); + +// Route Admin Pelanggan +Route::resource('pelanggans', PelangganController::class)->only(['index', 'show', 'destroy'])->middleware('auth'); + + + -Route::prefix('admin')->name('admin.')->group(function () { - Route::get('/kategori', [KategoriController::class, 'index'])->name('kategori.index'); - Route::post('/kategori', [KategoriController::class, 'store'])->name('kategori.store'); - Route::put('/kategori/{kategori}', [KategoriController::class, 'update'])->name('kategori.update'); - Route::delete('/kategori/{kategori}', [KategoriController::class, 'destroy'])->name('kategori.destroy'); -}); use App\Http\Controllers\Api\ReviewController; @@ -55,13 +65,5 @@ Route::prefix('admin')->name('admin.')->middleware('auth:admin')->group(function return redirect()->route('admin.reviews.index')->with('success', 'Ulasan berhasil dihapus'); })->name('reviews.destroy'); }); -use App\Http\Controllers\FiturController; -Route::prefix('admin')->name('admin.')->group(function () { - Route::get('/fitur', [FiturController::class, 'index'])->name('fitur.index'); - Route::post('/fitur', [FiturController::class, 'store'])->name('fitur.store'); - Route::get('/fitur/{id}', [FiturController::class, 'show'])->name('fitur.show'); - Route::put('/fitur/{id}', [FiturController::class, 'update'])->name('fitur.update'); - Route::delete('/fitur/{id}', [FiturController::class, 'destroy'])->name('fitur.destroy'); -});