[Update FormApi]
This commit is contained in:
parent
80c1fdda8b
commit
d4f5e5ef76
79
backend/app/Http/Controllers/Api/FormApiController.php
Normal file
79
backend/app/Http/Controllers/Api/FormApiController.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Pelanggan;
|
||||
use App\Models\PelangganDetail;
|
||||
use App\Models\Template;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FormApiController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
// ✅ Validasi dasar
|
||||
$rules = [
|
||||
'template_id' => 'required|exists:templates,id',
|
||||
'nama_pemesan' => 'required|string|max:255',
|
||||
'no_hp' => 'required|string|max:20',
|
||||
'email' => 'required|email',
|
||||
];
|
||||
|
||||
// ✅ Ambil template & fiturnya
|
||||
$template = Template::with(['fiturs', 'kategori'])->findOrFail($request->template_id);
|
||||
|
||||
// ✅ Loop fitur → generate aturan validasi dinamis
|
||||
foreach ($template->fiturs as $fitur) {
|
||||
$field = str_replace(' ', '_', strtolower($fitur->deskripsi)); // contoh: "Nama Lengkap Pria" → "nama_lengkap_pria"
|
||||
|
||||
// Aturan default: required string max 255
|
||||
$rules[$field] = 'nullable|string|max:255';
|
||||
|
||||
// Kalau fitur ada kata "tanggal"
|
||||
if (str_contains(strtolower($fitur->deskripsi), 'tanggal')) {
|
||||
$rules[$field] = 'nullable|date';
|
||||
}
|
||||
|
||||
// Kalau fitur ada kata "foto" atau "galeri"
|
||||
if (str_contains(strtolower($fitur->deskripsi), 'galeri')) {
|
||||
$rules['galeri'] = 'nullable|array|max:10';
|
||||
$rules['galeri.*'] = 'image|mimes:jpeg,png,jpg,gif|max:2048';
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ Jalankan validasi
|
||||
$data = $request->validate($rules);
|
||||
|
||||
// --- PROSES UPLOAD GALERI ---
|
||||
$galleryPaths = [];
|
||||
if ($request->hasFile('galeri')) {
|
||||
foreach ($request->file('galeri') as $file) {
|
||||
$galleryPaths[] = $file->store('gallery', 'public');
|
||||
}
|
||||
}
|
||||
$data['galeri'] = $galleryPaths;
|
||||
|
||||
// ✅ Simpan ke tabel pelanggan
|
||||
$pelanggan = Pelanggan::create([
|
||||
'nama_pemesan' => $data['nama_pemesan'],
|
||||
'nama_template' => $template->nama_template,
|
||||
'kategori' => $template->kategori->nama ?? '-',
|
||||
'email' => $data['email'],
|
||||
'no_tlpn' => $data['no_hp'],
|
||||
'harga' => $template->harga,
|
||||
]);
|
||||
|
||||
// ✅ Simpan detail form (dinamis)
|
||||
PelangganDetail::create([
|
||||
'pelanggan_id' => $pelanggan->id,
|
||||
'detail_form' => $data,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Form berhasil dikirim sesuai fitur template',
|
||||
'data' => $pelanggan->load('details')
|
||||
], 201);
|
||||
}
|
||||
}
|
||||
@ -1,80 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
// namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Pelanggan;
|
||||
use App\Models\PelangganDetail;
|
||||
use App\Models\Template; // ✅ tambahkan ini
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
// use App\Http\Controllers\Controller;
|
||||
// use App\Models\Pelanggan;
|
||||
// use App\Models\PelangganDetail;
|
||||
// use App\Models\Template; // ✅ tambahkan ini
|
||||
// use Illuminate\Http\Request;
|
||||
// use Illuminate\Support\Arr;
|
||||
|
||||
class KhitanApiController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'template_id' => 'required|exists:templates,id',
|
||||
'nama_pemesan' => 'required|string|max:255',
|
||||
'no_hp' => 'required|string|max:20',
|
||||
'email' => 'required|email',
|
||||
// class KhitanApiController extends Controller
|
||||
// {
|
||||
// public function store(Request $request)
|
||||
// {
|
||||
// $data = $request->validate([
|
||||
// 'template_id' => 'required|exists:templates,id',
|
||||
// 'nama_pemesan' => 'required|string|max:255',
|
||||
// 'no_hp' => 'required|string|max:20',
|
||||
// 'email' => 'required|email',
|
||||
|
||||
// Anak
|
||||
'nama_lengkap_anak' => 'required|string|max:255',
|
||||
'nama_panggilan_anak' => 'required|string|max:255',
|
||||
'bapak_anak' => 'nullable|string|max:255',
|
||||
'ibu_anak' => 'nullable|string|max:255',
|
||||
// // Anak
|
||||
// 'nama_lengkap_anak' => 'required|string|max:255',
|
||||
// 'nama_panggilan_anak' => 'required|string|max:255',
|
||||
// 'bapak_anak' => 'nullable|string|max:255',
|
||||
// 'ibu_anak' => 'nullable|string|max:255',
|
||||
|
||||
// Jadwal
|
||||
'hari_tanggal_acara' => 'nullable|date',
|
||||
'waktu_acara' => 'nullable|string',
|
||||
'alamat_acara' => 'nullable|string',
|
||||
'maps_acara' => 'nullable|string',
|
||||
// // Jadwal
|
||||
// 'hari_tanggal_acara' => 'nullable|date',
|
||||
// 'waktu_acara' => 'nullable|string',
|
||||
// 'alamat_acara' => 'nullable|string',
|
||||
// 'maps_acara' => 'nullable|string',
|
||||
|
||||
// Tambahan
|
||||
'no_rekening1' => 'nullable|string',
|
||||
'no_rekening2' => 'nullable|string',
|
||||
'link_musik' => 'nullable|string',
|
||||
'galeri' => 'nullable|array|max:5',
|
||||
'galeri.*' => 'image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
]);
|
||||
// // Tambahan
|
||||
// 'no_rekening1' => 'nullable|string',
|
||||
// 'no_rekening2' => 'nullable|string',
|
||||
// 'link_musik' => 'nullable|string',
|
||||
// 'galeri' => 'nullable|array|max:5',
|
||||
// 'galeri.*' => 'image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
// ]);
|
||||
|
||||
// --- PROSES UPLOAD GAMBAR ---
|
||||
$galleryPaths = [];
|
||||
if ($request->hasFile('galeri')) {
|
||||
foreach ($request->file('galeri') as $file) {
|
||||
// Simpan file ke storage/app/public/gallery dan dapatkan path-nya
|
||||
$path = $file->store('gallery', 'public');
|
||||
$galleryPaths[] = $path;
|
||||
}
|
||||
}
|
||||
// Tambahkan path gambar ke dalam data yang akan disimpan
|
||||
$data['galeri'] = $galleryPaths;
|
||||
// // --- PROSES UPLOAD GAMBAR ---
|
||||
// $galleryPaths = [];
|
||||
// if ($request->hasFile('galeri')) {
|
||||
// foreach ($request->file('galeri') as $file) {
|
||||
// // Simpan file ke storage/app/public/gallery dan dapatkan path-nya
|
||||
// $path = $file->store('gallery', 'public');
|
||||
// $galleryPaths[] = $path;
|
||||
// }
|
||||
// }
|
||||
// // Tambahkan path gambar ke dalam data yang akan disimpan
|
||||
// $data['galeri'] = $galleryPaths;
|
||||
|
||||
|
||||
// ✅ Ambil template dari database
|
||||
$template = Template::with('kategori')->findOrFail($data['template_id']);
|
||||
// // ✅ Ambil template dari database
|
||||
// $template = Template::with('kategori')->findOrFail($data['template_id']);
|
||||
|
||||
// ✅ Simpan ke tabel pelanggan
|
||||
$pelanggan = Pelanggan::create([
|
||||
'nama_pemesan' => $data['nama_pemesan'],
|
||||
'nama_template' => $template->nama_template,
|
||||
'kategori' => $template->kategori->nama ?? 'khitan',
|
||||
'email' => $data['email'],
|
||||
'no_tlpn' => $data['no_hp'],
|
||||
'harga' => $template->harga,
|
||||
]);
|
||||
// // ✅ Simpan ke tabel pelanggan
|
||||
// $pelanggan = Pelanggan::create([
|
||||
// 'nama_pemesan' => $data['nama_pemesan'],
|
||||
// 'nama_template' => $template->nama_template,
|
||||
// 'kategori' => $template->kategori->nama ?? 'khitan',
|
||||
// 'email' => $data['email'],
|
||||
// 'no_tlpn' => $data['no_hp'],
|
||||
// 'harga' => $template->harga,
|
||||
// ]);
|
||||
|
||||
// ✅ Simpan detail form ke tabel pelanggan_details
|
||||
PelangganDetail::create([
|
||||
'pelanggan_id' => $pelanggan->id,
|
||||
'detail_form' => $data,
|
||||
]);
|
||||
// // ✅ Simpan detail form ke tabel pelanggan_details
|
||||
// PelangganDetail::create([
|
||||
// 'pelanggan_id' => $pelanggan->id,
|
||||
// 'detail_form' => $data,
|
||||
// ]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Form khitan berhasil dikirim',
|
||||
'data' => $pelanggan->load('details')
|
||||
], 201);
|
||||
}
|
||||
}
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'message' => 'Form khitan berhasil dikirim',
|
||||
// 'data' => $pelanggan->load('details')
|
||||
// ], 201);
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,101 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
// namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Pelanggan;
|
||||
use App\Models\PelangganDetail;
|
||||
use App\Models\Template; // ✅ tambahkan ini
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
// use App\Http\Controllers\Controller;
|
||||
// use App\Models\Pelanggan;
|
||||
// use App\Models\PelangganDetail;
|
||||
// use App\Models\Template; // ✅ tambahkan ini
|
||||
// use Illuminate\Http\Request;
|
||||
// use Illuminate\Support\Arr;
|
||||
|
||||
class PernikahanApiController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'template_id' => 'required|exists:templates,id',
|
||||
'nama_pemesan' => 'required|string|max:255',
|
||||
'no_hp' => 'required|string|max:20',
|
||||
'email' => 'required|email',
|
||||
// class PernikahanApiController extends Controller
|
||||
// {
|
||||
// public function store(Request $request)
|
||||
// {
|
||||
// $data = $request->validate([
|
||||
// 'template_id' => 'required|exists:templates,id',
|
||||
// 'nama_pemesan' => 'required|string|max:255',
|
||||
// 'no_hp' => 'required|string|max:20',
|
||||
// 'email' => 'required|email',
|
||||
|
||||
// Pria
|
||||
'nama_lengkap_pria' => 'required|string|max:255',
|
||||
'nama_panggilan_pria' => 'required|string|max:255',
|
||||
'bapak_pria' => 'nullable|string|max:255',
|
||||
'ibu_pria' => 'nullable|string|max:255',
|
||||
'instagram_pria' => 'nullable|string',
|
||||
'facebook_pria' => 'nullable|string',
|
||||
'twitter_pria' => 'nullable|string',
|
||||
// // Pria
|
||||
// 'nama_lengkap_pria' => 'required|string|max:255',
|
||||
// 'nama_panggilan_pria' => 'required|string|max:255',
|
||||
// 'bapak_pria' => 'nullable|string|max:255',
|
||||
// 'ibu_pria' => 'nullable|string|max:255',
|
||||
// 'instagram_pria' => 'nullable|string',
|
||||
// 'facebook_pria' => 'nullable|string',
|
||||
// 'twitter_pria' => 'nullable|string',
|
||||
|
||||
// Wanita
|
||||
'nama_lengkap_wanita' => 'required|string|max:255',
|
||||
'nama_panggilan_wanita' => 'required|string|max:255',
|
||||
'bapak_wanita' => 'nullable|string|max:255',
|
||||
'ibu_wanita' => 'nullable|string|max:255',
|
||||
'instagram_wanita' => 'nullable|string',
|
||||
'facebook_wanita' => 'nullable|string',
|
||||
'twitter_wanita' => 'nullable|string',
|
||||
// // Wanita
|
||||
// 'nama_lengkap_wanita' => 'required|string|max:255',
|
||||
// 'nama_panggilan_wanita' => 'required|string|max:255',
|
||||
// 'bapak_wanita' => 'nullable|string|max:255',
|
||||
// 'ibu_wanita' => 'nullable|string|max:255',
|
||||
// 'instagram_wanita' => 'nullable|string',
|
||||
// 'facebook_wanita' => 'nullable|string',
|
||||
// 'twitter_wanita' => 'nullable|string',
|
||||
|
||||
// Cerita
|
||||
'cerita_kita' => 'nullable|string',
|
||||
// // Cerita
|
||||
// 'cerita_kita' => 'nullable|string',
|
||||
|
||||
// Akad
|
||||
'hari_tanggal_akad' => 'nullable|date',
|
||||
'waktu_akad' => 'nullable|string',
|
||||
'alamat_akad' => 'nullable|string',
|
||||
'maps_akad' => 'nullable|string',
|
||||
// // Akad
|
||||
// 'hari_tanggal_akad' => 'nullable|date',
|
||||
// 'waktu_akad' => 'nullable|string',
|
||||
// 'alamat_akad' => 'nullable|string',
|
||||
// 'maps_akad' => 'nullable|string',
|
||||
|
||||
// Resepsi
|
||||
'hari_tanggal_resepsi' => 'nullable|date',
|
||||
'waktu_resepsi' => 'nullable|string',
|
||||
'alamat_resepsi' => 'nullable|string',
|
||||
'maps_resepsi' => 'nullable|string',
|
||||
// // Resepsi
|
||||
// 'hari_tanggal_resepsi' => 'nullable|date',
|
||||
// 'waktu_resepsi' => 'nullable|string',
|
||||
// 'alamat_resepsi' => 'nullable|string',
|
||||
// 'maps_resepsi' => 'nullable|string',
|
||||
|
||||
// Tambahan
|
||||
'no_rekening1' => 'nullable|string',
|
||||
'no_rekening2' => 'nullable|string',
|
||||
'link_musik' => 'nullable|string',
|
||||
'galeri' => 'nullable|array|max:10',
|
||||
'galeri.*' => 'image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
]);
|
||||
// // Tambahan
|
||||
// 'no_rekening1' => 'nullable|string',
|
||||
// 'no_rekening2' => 'nullable|string',
|
||||
// 'link_musik' => 'nullable|string',
|
||||
// 'galeri' => 'nullable|array|max:10',
|
||||
// 'galeri.*' => 'image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
// ]);
|
||||
|
||||
// --- PROSES UPLOAD GAMBAR ---
|
||||
$galleryPaths = [];
|
||||
if ($request->hasFile('galeri')) {
|
||||
foreach ($request->file('galeri') as $file) {
|
||||
// Simpan file ke storage/app/public/gallery dan dapatkan path-nya
|
||||
$path = $file->store('gallery', 'public');
|
||||
$galleryPaths[] = $path;
|
||||
}
|
||||
}
|
||||
// Ganti 'galeri' di $data dengan array path yang sudah disimpan
|
||||
$data['galeri'] = $galleryPaths;
|
||||
// // --- PROSES UPLOAD GAMBAR ---
|
||||
// $galleryPaths = [];
|
||||
// if ($request->hasFile('galeri')) {
|
||||
// foreach ($request->file('galeri') as $file) {
|
||||
// // Simpan file ke storage/app/public/gallery dan dapatkan path-nya
|
||||
// $path = $file->store('gallery', 'public');
|
||||
// $galleryPaths[] = $path;
|
||||
// }
|
||||
// }
|
||||
// // Ganti 'galeri' di $data dengan array path yang sudah disimpan
|
||||
// $data['galeri'] = $galleryPaths;
|
||||
|
||||
|
||||
// ✅ Ambil template berdasarkan template_id
|
||||
$template = Template::with('kategori')->findOrFail($data['template_id']);
|
||||
// // ✅ Ambil template berdasarkan template_id
|
||||
// $template = Template::with('kategori')->findOrFail($data['template_id']);
|
||||
|
||||
// ✅ Simpan ke tabel pelanggan
|
||||
$pelanggan = Pelanggan::create([
|
||||
'nama_pemesan' => $data['nama_pemesan'],
|
||||
'nama_template' => $template->nama_template,
|
||||
'kategori' => $template->kategori->nama ?? '-',
|
||||
'email' => $data['email'],
|
||||
'no_tlpn' => $data['no_hp'],
|
||||
'harga' => $template->harga,
|
||||
]);
|
||||
// // ✅ Simpan ke tabel pelanggan
|
||||
// $pelanggan = Pelanggan::create([
|
||||
// 'nama_pemesan' => $data['nama_pemesan'],
|
||||
// 'nama_template' => $template->nama_template,
|
||||
// 'kategori' => $template->kategori->nama ?? '-',
|
||||
// 'email' => $data['email'],
|
||||
// 'no_tlpn' => $data['no_hp'],
|
||||
// 'harga' => $template->harga,
|
||||
// ]);
|
||||
|
||||
// ✅ Simpan detail form ke tabel pelanggan_details
|
||||
PelangganDetail::create([
|
||||
'pelanggan_id' => $pelanggan->id,
|
||||
'detail_form' => $data,
|
||||
]);
|
||||
// // ✅ Simpan detail form ke tabel pelanggan_details
|
||||
// PelangganDetail::create([
|
||||
// 'pelanggan_id' => $pelanggan->id,
|
||||
// 'detail_form' => $data,
|
||||
// ]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Form pernikahan berhasil dikirim',
|
||||
'data' => $pelanggan->load('details')
|
||||
], 201);
|
||||
}
|
||||
}
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'message' => 'Form pernikahan berhasil dikirim',
|
||||
// 'data' => $pelanggan->load('details')
|
||||
// ], 201);
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,75 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
// namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Pelanggan;
|
||||
use App\Models\PelangganDetail;
|
||||
use App\Models\Template; // ✅ tambahkan ini
|
||||
use Illuminate\Http\Request;
|
||||
// use App\Http\Controllers\Controller;
|
||||
// use App\Models\Pelanggan;
|
||||
// use App\Models\PelangganDetail;
|
||||
// use App\Models\Template; // ✅ tambahkan ini
|
||||
// use Illuminate\Http\Request;
|
||||
|
||||
class UlangTahunApiController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'template_id' => 'required|exists:templates,id',
|
||||
'nama_pemesan' => 'required|string|max:255',
|
||||
'no_hp' => 'required|string|max:20',
|
||||
'email' => 'required|email',
|
||||
// class UlangTahunApiController extends Controller
|
||||
// {
|
||||
// public function store(Request $request)
|
||||
// {
|
||||
// $data = $request->validate([
|
||||
// 'template_id' => 'required|exists:templates,id',
|
||||
// 'nama_pemesan' => 'required|string|max:255',
|
||||
// 'no_hp' => 'required|string|max:20',
|
||||
// 'email' => 'required|email',
|
||||
|
||||
// Data Anak
|
||||
'nama_lengkap_anak' => 'required|string|max:255',
|
||||
'nama_panggilan_anak' => 'required|string|max:100',
|
||||
'bapak_anak' => 'required|string|max:255',
|
||||
'ibu_anak' => 'required|string|max:255',
|
||||
'umur_dirayakan' => 'required|string|max:10',
|
||||
'anak_ke' => 'required|string|max:5',
|
||||
// // Data Anak
|
||||
// 'nama_lengkap_anak' => 'required|string|max:255',
|
||||
// 'nama_panggilan_anak' => 'required|string|max:100',
|
||||
// 'bapak_anak' => 'required|string|max:255',
|
||||
// 'ibu_anak' => 'required|string|max:255',
|
||||
// 'umur_dirayakan' => 'required|string|max:10',
|
||||
// 'anak_ke' => 'required|string|max:5',
|
||||
|
||||
// Jadwal
|
||||
'hari_tanggal_acara' => 'required|date',
|
||||
'waktu_acara' => 'required|string|max:50',
|
||||
'alamat_acara' => 'required|string',
|
||||
'maps_acara' => 'nullable|string',
|
||||
'link_musik' => 'nullable|string',
|
||||
// --- PERBAIKAN VALIDASI GALERI ---
|
||||
'galeri' => 'nullable|array|max:5',
|
||||
'galeri.*' => 'image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
]);
|
||||
// // Jadwal
|
||||
// 'hari_tanggal_acara' => 'required|date',
|
||||
// 'waktu_acara' => 'required|string|max:50',
|
||||
// 'alamat_acara' => 'required|string',
|
||||
// 'maps_acara' => 'nullable|string',
|
||||
// 'link_musik' => 'nullable|string',
|
||||
// // --- PERBAIKAN VALIDASI GALERI ---
|
||||
// 'galeri' => 'nullable|array|max:5',
|
||||
// 'galeri.*' => 'image|mimes:jpeg,png,jpg,gif|max:2048',
|
||||
// ]);
|
||||
|
||||
// --- PROSES UPLOAD GAMBAR ---
|
||||
$galleryPaths = [];
|
||||
if ($request->hasFile('galeri')) {
|
||||
foreach ($request->file('galeri') as $file) {
|
||||
$path = $file->store('gallery', 'public');
|
||||
$galleryPaths[] = $path;
|
||||
}
|
||||
}
|
||||
$data['galeri'] = $galleryPaths;
|
||||
// // --- PROSES UPLOAD GAMBAR ---
|
||||
// $galleryPaths = [];
|
||||
// if ($request->hasFile('galeri')) {
|
||||
// foreach ($request->file('galeri') as $file) {
|
||||
// $path = $file->store('gallery', 'public');
|
||||
// $galleryPaths[] = $path;
|
||||
// }
|
||||
// }
|
||||
// $data['galeri'] = $galleryPaths;
|
||||
|
||||
// ✅ Ambil template berdasarkan template_id
|
||||
$template = Template::with('kategori')->findOrFail($data['template_id']);
|
||||
// // ✅ Ambil template berdasarkan template_id
|
||||
// $template = Template::with('kategori')->findOrFail($data['template_id']);
|
||||
|
||||
// ✅ Simpan ke tabel pelanggan
|
||||
$pelanggan = Pelanggan::create([
|
||||
'nama_pemesan' => $data['nama_pemesan'],
|
||||
'nama_template' => $template->nama_template,
|
||||
'kategori' => $template->kategori->nama ?? 'ulang_tahun',
|
||||
'email' => $data['email'],
|
||||
'no_tlpn' => $data['no_hp'],
|
||||
'harga' => $template->harga,
|
||||
]);
|
||||
// // ✅ Simpan ke tabel pelanggan
|
||||
// $pelanggan = Pelanggan::create([
|
||||
// 'nama_pemesan' => $data['nama_pemesan'],
|
||||
// 'nama_template' => $template->nama_template,
|
||||
// 'kategori' => $template->kategori->nama ?? 'ulang_tahun',
|
||||
// 'email' => $data['email'],
|
||||
// 'no_tlpn' => $data['no_hp'],
|
||||
// 'harga' => $template->harga,
|
||||
// ]);
|
||||
|
||||
// ✅ Simpan detail form ke tabel pelanggan_details
|
||||
PelangganDetail::create([
|
||||
'pelanggan_id' => $pelanggan->id,
|
||||
'detail_form' => $data,
|
||||
]);
|
||||
// // ✅ Simpan detail form ke tabel pelanggan_details
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'message' => 'Form ulang tahun berhasil dikirim',
|
||||
// 'data' => $pelanggan->load('details')
|
||||
// ], 201);
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -8,11 +8,15 @@ use App\Http\Controllers\Api\PernikahanApiController;
|
||||
use App\Http\Controllers\Api\UlangTahunApiController;
|
||||
use App\Http\Controllers\Api\KhitanApiController;
|
||||
use App\Http\Controllers\Api\TemplateApiController;
|
||||
use App\Http\Controllers\Api\FormApiController;
|
||||
|
||||
// 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']);
|
||||
// Form API (universal, dinamis berdasarkan template_id)
|
||||
Route::post('form', [FormApiController::class, 'store']);
|
||||
|
||||
// // 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']);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user