'Ruangan Pelayanan' ]; return view('roomService.index', $data); } /** * Show the form for creating a new resource. */ public function create() { // } /** * Store a newly created resource in storage. */ public function store(Request $request) { try { $names = request('name'); foreach ($names as $name) { if (!empty($name)) { $payload = [ 'name' => $name, 'uid'=> (new helperController)->getUid() ]; roomService::create($payload); } } return response()->json([ 'status' => 'success', 'message' => 'Berhasil! menambahkan data' ]); } catch (\Throwable $th) { return response()->json([ 'status' => 'error', 'message' => 'gagal! menambahkan data' . $th->getMessage() ]); } } /** * Display the specified resource. */ public function show(roomService $roomService) { // } /** * Show the form for editing the specified resource. */ public function edit(roomService $roomService) { // } /** * Update the specified resource in storage. */ public function update(Request $request, string $uid) { try { $asuransi = roomService::where('uid', $uid)->first(); $payload = ['name' => request('name')]; $asuransi->update($payload); return response()->json([ 'status' => 'success', 'message' => 'Berhasil! edit data' ]); } catch (\Throwable $th) { return response()->json([ 'status' => 'error', 'message' => 'gagal! edit data' . $th->getMessage() ]); } } /** * Remove the specified resource from storage. */ public function destroy(string $uid) { try { roomService::where('uid', $uid)->update([ 'is_delete' => true ]); return response()->json([ 'status' => 'success', 'message' => 'Berhasil! Hapus data' ]); } catch (\Throwable $th) { return response()->json([ 'status' => 'error', 'message' => 'gagal! hapus data' . $th->getMessage() ]); } } public function datatable(){ return roomService::where('is_delete', false)->get(); } }