[Ubah All]
This commit is contained in:
parent
bfbc8db1fc
commit
44dfdec0b0
21
backend/app/Http/Controllers/Api/KategoriApiController.php
Normal file
21
backend/app/Http/Controllers/Api/KategoriApiController.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Kategori;
|
||||
|
||||
class KategoriApiController extends Controller
|
||||
{
|
||||
// Ambil semua kategori
|
||||
public function index()
|
||||
{
|
||||
return response()->json(Kategori::all());
|
||||
}
|
||||
|
||||
// Ambil detail satu kategori
|
||||
public function show(Kategori $kategori)
|
||||
{
|
||||
return response()->json($kategori);
|
||||
}
|
||||
}
|
48
backend/app/Http/Controllers/Api/KhitanApiController.php
Normal file
48
backend/app/Http/Controllers/Api/KhitanApiController.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Pelanggan;
|
||||
use App\Models\PelangganDetail;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class KhitanApiController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->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);
|
||||
}
|
||||
}
|
49
backend/app/Http/Controllers/Api/PernikahanApiController.php
Normal file
49
backend/app/Http/Controllers/Api/PernikahanApiController.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Pelanggan;
|
||||
use App\Models\PelangganDetail;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PernikahanApiController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->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);
|
||||
}
|
||||
}
|
21
backend/app/Http/Controllers/Api/TemplateApiController.php
Normal file
21
backend/app/Http/Controllers/Api/TemplateApiController.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Template;
|
||||
|
||||
class TemplateApiController extends Controller
|
||||
{
|
||||
// User hanya bisa lihat semua template
|
||||
public function index()
|
||||
{
|
||||
return response()->json(Template::with(['kategori','fitur'])->get());
|
||||
}
|
||||
|
||||
// User bisa lihat detail 1 template
|
||||
public function show(Template $template)
|
||||
{
|
||||
return response()->json($template->load(['kategori','fitur']));
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Template;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class TemplateController extends Controller
|
||||
{
|
||||
/**
|
||||
* Mengambil daftar semua template beserta kategorinya.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$templates = Template::with('kategori')->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);
|
||||
}
|
||||
}
|
51
backend/app/Http/Controllers/Api/UlangTahunApiController.php
Normal file
51
backend/app/Http/Controllers/Api/UlangTahunApiController.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Pelanggan;
|
||||
use App\Models\PelangganDetail;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UlangTahunApiController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->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);
|
||||
}
|
||||
}
|
@ -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!');
|
||||
}
|
||||
}
|
||||
|
@ -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!');
|
||||
}
|
||||
}
|
||||
|
29
backend/app/Http/Controllers/PelangganController.php
Normal file
29
backend/app/Http/Controllers/PelangganController.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Pelanggan;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PelangganController extends Controller
|
||||
{
|
||||
// Tampilkan semua pelanggan (admin)
|
||||
public function index()
|
||||
{
|
||||
$pelanggans = Pelanggan::with('details')->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!');
|
||||
}
|
||||
}
|
63
backend/app/Http/Controllers/TemplateController.php
Normal file
63
backend/app/Http/Controllers/TemplateController.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Template;
|
||||
use App\Models\Kategori;
|
||||
use App\Models\Fitur;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TemplateController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$templates = Template::with(['kategori','fitur'])->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!');
|
||||
}
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
// app/Models/Fitur.php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fitur extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = ['deskripsi'];
|
||||
|
||||
protected $fillable = [
|
||||
'nama_fitur',
|
||||
];
|
||||
public function templates()
|
||||
{
|
||||
return $this->hasMany(Template::class);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,11 @@
|
||||
<?php
|
||||
|
||||
// app/Models/Kategori.php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Kategori extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['nama', 'deskripsi', 'foto'];
|
||||
|
||||
public function templates()
|
||||
|
19
backend/app/Models/Khitan.php
Normal file
19
backend/app/Models/Khitan.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
// app/Models/Khitan.php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Khitan extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'template_id', 'nama_pemesan', 'no_hp', 'email',
|
||||
'nama_panjang', 'nama_pendek', 'nama_orangtua',
|
||||
'alamat', 'tanggal_acara', 'link_musik', 'galeri',
|
||||
'kata_pengucapan'
|
||||
];
|
||||
|
||||
public function template() {
|
||||
return $this->belongsTo(Template::class);
|
||||
}
|
||||
}
|
25
backend/app/Models/Pelanggan.php
Normal file
25
backend/app/Models/Pelanggan.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Pelanggan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'nama_pemesan',
|
||||
'nama_template',
|
||||
'kategori',
|
||||
'email',
|
||||
'no_tlpn',
|
||||
'harga',
|
||||
];
|
||||
|
||||
public function details()
|
||||
{
|
||||
return $this->hasOne(PelangganDetail::class);
|
||||
}
|
||||
}
|
22
backend/app/Models/PelangganDetail.php
Normal file
22
backend/app/Models/PelangganDetail.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PelangganDetail extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['pelanggan_id', 'detail_form'];
|
||||
|
||||
protected $casts = [
|
||||
'detail_form' => 'array',
|
||||
];
|
||||
|
||||
public function pelanggan()
|
||||
{
|
||||
return $this->belongsTo(Pelanggan::class);
|
||||
}
|
||||
}
|
18
backend/app/Models/Pernikahan.php
Normal file
18
backend/app/Models/Pernikahan.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
// app/Models/Pernikahan.php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Pernikahan extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'template_id', 'nama_pemesan', 'no_hp', 'email',
|
||||
'nama_pria', 'nama_wanita', 'alamat', 'tanggal_acara',
|
||||
'link_undangan', 'kata_pengucapan', 'galeri', 'link_musik'
|
||||
];
|
||||
|
||||
public function template() {
|
||||
return $this->belongsTo(Template::class);
|
||||
}
|
||||
}
|
@ -1,31 +1,30 @@
|
||||
<?php
|
||||
|
||||
// app/Models/Template.php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Template extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = ['nama_template', 'kategori_id', 'fitur_id', 'foto'];
|
||||
|
||||
protected $table = 'templates';
|
||||
protected $primaryKey = 'id_template';
|
||||
|
||||
protected $fillable = [
|
||||
'kategori_id', // Sesuaikan dengan nama kolom di database yang sudah benar
|
||||
'nama_template',
|
||||
'fitur',
|
||||
'foto',
|
||||
];
|
||||
|
||||
public function kategori()
|
||||
{
|
||||
return $this->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);
|
||||
}
|
||||
|
||||
public function pernikahan() {
|
||||
return $this->hasOne(Pernikahan::class);
|
||||
}
|
||||
|
||||
public function ulangTahun() {
|
||||
return $this->hasOne(UlangTahun::class);
|
||||
}
|
||||
|
||||
public function khitan() {
|
||||
return $this->hasOne(Khitan::class);
|
||||
}
|
||||
}
|
19
backend/app/Models/UlangTahun.php
Normal file
19
backend/app/Models/UlangTahun.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
// app/Models/UlangTahun.php
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UlangTahun extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'template_id', 'nama_pemesan', 'no_hp', 'email',
|
||||
'nama_panjang', 'nama_panggilan', 'ulang_tahun_ke', 'anak_ke',
|
||||
'nama_orangtua', 'alamat', 'tanggal_acara', 'link_musik',
|
||||
'kata_pengucapan', 'galeri'
|
||||
];
|
||||
|
||||
public function template() {
|
||||
return $this->belongsTo(Template::class);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
<?
|
||||
|
||||
// database/migrations/xxxx_xx_xx_create_kategoris_table.php
|
||||
// database/migrations/2025_09_08_000001_create_kategoris_table.php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
@ -1,22 +1,20 @@
|
||||
<?php
|
||||
|
||||
// database/migrations/2025_09_08_000002_create_fiturs_table.php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('fiturs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nama_fitur');
|
||||
$table->text('deskripsi');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
public function down(): void {
|
||||
Schema::dropIfExists('fiturs');
|
||||
}
|
||||
};
|
||||
|
@ -1,34 +1,24 @@
|
||||
<?php
|
||||
|
||||
// database/migrations/2025_09_08_000003_create_templates_table.php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('templates', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('pelanggans', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('pelanggan_details', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
// database/migrations/2025_09_08_000004_create_pernikahans_table.php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('pernikahans', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
// database/migrations/2025_09_08_000005_create_ulang_tahuns_table.php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('ulang_tahuns', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
// database/migrations/2025_09_08_000006_create_khitans_table.php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('khitans', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
};
|
||||
|
@ -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']);
|
||||
|
||||
|
@ -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');
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user