102 lines
4.0 KiB
PHP
102 lines
4.0 KiB
PHP
<?php
|
|
|
|
// 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;
|
|
|
|
// 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',
|
|
|
|
// // 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',
|
|
|
|
// // 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',
|
|
|
|
// // 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;
|
|
|
|
|
|
// // ✅ 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 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);
|
|
// }
|
|
// }
|