[Ubah Controller Pernikahan, HBD, Khitan]
This commit is contained in:
parent
3c2ca564fb
commit
36dffc322e
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Pelanggan;
|
use App\Models\Pelanggan;
|
||||||
use App\Models\PelangganDetail;
|
use App\Models\PelangganDetail;
|
||||||
|
use App\Models\Template; // ✅ tambahkan ini
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class KhitanApiController extends Controller
|
class KhitanApiController extends Controller
|
||||||
@ -36,15 +37,20 @@ class KhitanApiController extends Controller
|
|||||||
'galeri' => 'nullable|string',
|
'galeri' => 'nullable|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// ✅ Ambil template dari database
|
||||||
|
$template = Template::with('kategori')->findOrFail($data['template_id']);
|
||||||
|
|
||||||
|
// ✅ Simpan ke tabel pelanggan
|
||||||
$pelanggan = Pelanggan::create([
|
$pelanggan = Pelanggan::create([
|
||||||
'nama_pemesan' => $data['nama_pemesan'],
|
'nama_pemesan' => $data['nama_pemesan'],
|
||||||
'nama_template' => 'Template Khitan',
|
'nama_template' => $template->nama_template,
|
||||||
'kategori' => 'khitan',
|
'kategori' => $template->kategori->nama ?? 'khitan',
|
||||||
'email' => $data['email'],
|
'email' => $data['email'],
|
||||||
'no_tlpn' => $data['no_hp'],
|
'no_tlpn' => $data['no_hp'],
|
||||||
'harga' => 0,
|
'harga' => $template->harga,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// ✅ Simpan detail form ke tabel pelanggan_details
|
||||||
PelangganDetail::create([
|
PelangganDetail::create([
|
||||||
'pelanggan_id' => $pelanggan->id,
|
'pelanggan_id' => $pelanggan->id,
|
||||||
'detail_form' => $data,
|
'detail_form' => $data,
|
||||||
@ -53,7 +59,7 @@ class KhitanApiController extends Controller
|
|||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => 'Form khitan berhasil dikirim',
|
'message' => 'Form khitan berhasil dikirim',
|
||||||
'data' => $pelanggan->load('details')
|
'data' => $pelanggan->load('details')
|
||||||
], 201);
|
], 201);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Pelanggan;
|
use App\Models\Pelanggan;
|
||||||
use App\Models\PelangganDetail;
|
use App\Models\PelangganDetail;
|
||||||
|
use App\Models\Template; // ✅ tambahkan ini
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class PernikahanApiController extends Controller
|
class PernikahanApiController extends Controller
|
||||||
@ -16,6 +17,7 @@ class PernikahanApiController extends Controller
|
|||||||
'nama_pemesan' => 'required|string|max:255',
|
'nama_pemesan' => 'required|string|max:255',
|
||||||
'no_hp' => 'required|string|max:20',
|
'no_hp' => 'required|string|max:20',
|
||||||
'email' => 'required|email',
|
'email' => 'required|email',
|
||||||
|
|
||||||
// Pria
|
// Pria
|
||||||
'nama_lengkap_pria' => 'required|string|max:255',
|
'nama_lengkap_pria' => 'required|string|max:255',
|
||||||
'nama_panggilan_pria' => 'required|string|max:255',
|
'nama_panggilan_pria' => 'required|string|max:255',
|
||||||
@ -56,15 +58,20 @@ class PernikahanApiController extends Controller
|
|||||||
'galeri' => 'nullable|string',
|
'galeri' => 'nullable|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// ✅ Ambil template berdasarkan template_id
|
||||||
|
$template = Template::with('kategori')->findOrFail($data['template_id']);
|
||||||
|
|
||||||
|
// ✅ Simpan ke tabel pelanggan
|
||||||
$pelanggan = Pelanggan::create([
|
$pelanggan = Pelanggan::create([
|
||||||
'nama_pemesan' => $data['nama_pemesan'],
|
'nama_pemesan' => $data['nama_pemesan'],
|
||||||
'nama_template' => 'Template Pernikahan',
|
'nama_template' => $template->nama_template,
|
||||||
'kategori' => 'pernikahan',
|
'kategori' => $template->kategori->nama ?? '-',
|
||||||
'email' => $data['email'],
|
'email' => $data['email'],
|
||||||
'no_tlpn' => $data['no_hp'],
|
'no_tlpn' => $data['no_hp'],
|
||||||
'harga' => 0,
|
'harga' => $template->harga,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// ✅ Simpan detail form ke tabel pelanggan_details
|
||||||
PelangganDetail::create([
|
PelangganDetail::create([
|
||||||
'pelanggan_id' => $pelanggan->id,
|
'pelanggan_id' => $pelanggan->id,
|
||||||
'detail_form' => $data,
|
'detail_form' => $data,
|
||||||
@ -73,7 +80,7 @@ class PernikahanApiController extends Controller
|
|||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => 'Form pernikahan berhasil dikirim',
|
'message' => 'Form pernikahan berhasil dikirim',
|
||||||
'data' => $pelanggan->load('details')
|
'data' => $pelanggan->load('details')
|
||||||
], 201);
|
], 201);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Pelanggan;
|
use App\Models\Pelanggan;
|
||||||
use App\Models\PelangganDetail;
|
use App\Models\PelangganDetail;
|
||||||
|
use App\Models\Template; // ✅ tambahkan ini
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class UlangTahunApiController extends Controller
|
class UlangTahunApiController extends Controller
|
||||||
@ -17,32 +18,37 @@ class UlangTahunApiController extends Controller
|
|||||||
'no_hp' => 'required|string|max:20',
|
'no_hp' => 'required|string|max:20',
|
||||||
'email' => 'required|email',
|
'email' => 'required|email',
|
||||||
|
|
||||||
//Data
|
// Data Anak
|
||||||
'nama_lengkap_anak' => 'required|string|max:255',
|
'nama_lengkap_anak' => 'required|string|max:255',
|
||||||
'nama_panggilan_anak' => 'required|string|max:100',
|
'nama_panggilan_anak' => 'required|string|max:100',
|
||||||
'bapak_anak' => 'required|string|max:255',
|
'bapak_anak' => 'required|string|max:255',
|
||||||
'ibu_anak' => 'required|string|max:255',
|
'ibu_anak' => 'required|string|max:255',
|
||||||
'umur_dirayakan' => 'required|string|max:10',
|
'umur_dirayakan' => 'required|string|max:10',
|
||||||
'anak_ke' => 'required|string|max:5',
|
'anak_ke' => 'required|string|max:5',
|
||||||
|
|
||||||
//Jadwal
|
// Jadwal
|
||||||
'hari_tanggal_acara' => 'required|date',
|
'hari_tanggal_acara' => 'required|date',
|
||||||
'waktu_acara' => 'required|string|max:50',
|
'waktu_acara' => 'required|string|max:50',
|
||||||
'alamat_acara' => 'required|string',
|
'alamat_acara' => 'required|string',
|
||||||
'maps_acara' => 'nullable|string',
|
'maps_acara' => 'nullable|string',
|
||||||
'link_musik' => 'nullable|string',
|
'link_musik' => 'nullable|string',
|
||||||
'galeri' => 'nullable|string',
|
'galeri' => 'nullable|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// ✅ Ambil template berdasarkan template_id
|
||||||
|
$template = Template::with('kategori')->findOrFail($data['template_id']);
|
||||||
|
|
||||||
|
// ✅ Simpan ke tabel pelanggan
|
||||||
$pelanggan = Pelanggan::create([
|
$pelanggan = Pelanggan::create([
|
||||||
'nama_pemesan' => $data['nama_pemesan'],
|
'nama_pemesan' => $data['nama_pemesan'],
|
||||||
'nama_template' => 'Template Ulang Tahun',
|
'nama_template' => $template->nama_template,
|
||||||
'kategori' => 'ulang_tahun',
|
'kategori' => $template->kategori->nama ?? 'ulang_tahun',
|
||||||
'email' => $data['email'],
|
'email' => $data['email'],
|
||||||
'no_tlpn' => $data['no_hp'],
|
'no_tlpn' => $data['no_hp'],
|
||||||
'harga' => 0,
|
'harga' => $template->harga,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// ✅ Simpan detail form ke tabel pelanggan_details
|
||||||
PelangganDetail::create([
|
PelangganDetail::create([
|
||||||
'pelanggan_id' => $pelanggan->id,
|
'pelanggan_id' => $pelanggan->id,
|
||||||
'detail_form' => $data,
|
'detail_form' => $data,
|
||||||
@ -51,7 +57,7 @@ class UlangTahunApiController extends Controller
|
|||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'message' => 'Form ulang tahun berhasil dikirim',
|
'message' => 'Form ulang tahun berhasil dikirim',
|
||||||
'data' => $pelanggan->load('details')
|
'data' => $pelanggan->load('details')
|
||||||
], 201);
|
], 201);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user