generateCode(); } else { return $kode_unik; } } /** * Display a listing of the resource. */ public function index() { // } /** * Show the form for creating a new resource. */ public function create() { // } /** * Store a newly created resource in storage. */ public function store(Request $request) { try { $request->validate([ 'nama_lengkap' => ['required', 'string'], 'email' => ['required', 'string'], 'no_telp' => ['required', 'string'], 'tgl_booking' => ['required', 'string'], 'deskripsi_tambahan' => ['required', 'string'] ]); $kode_unik = $this->generateCode(); BookingModel::create([ 'nama_lengkap' => $request->nama_lengkap, 'email' => $request->email, 'no_telp' => $request->no_telp, 'tgl_booking' => $request->tgl_booking, 'deskripsi_tambahan' => $request->deskripsi_tambahan, 'kode_unik' => $kode_unik ]); return response()->json([ 'status' => true, 'msg' => 'Booking success!' ]); } catch(\Exception $e) { return response()->json([ 'status' => false, 'msg' => $e->getMessage() ]); } } /** * Display the specified resource. */ public function show(string $id) { // } /** * Show the form for editing the specified resource. */ public function edit(string $id) { // } /** * Update the specified resource in storage. */ public function update(Request $request, string $id) { // } /** * Remove the specified resource from storage. */ public function destroy(string $id) { // } }