email); return view('user.contact.index',['contacts'=>$contacts]); } /** * Show the form for creating a new resource. */ public function create() { // } /** * Store a newly created resource in storage. */ public function store(Request $request) { $result = Contact::create([ 'pemilik_kontak' => Auth::user()->email, 'relasi_kontak' => $request->relasi_kontak, ]); if($result){ return response()->json([ 'status' => true, 'message' => $result, ]); }else{ return response()->json([ 'status' => false, 'message' => $result, ]); } } /** * Display the specified resource. */ public function show(Contact $contact) { // } /** * Show the form for editing the specified resource. */ public function edit(Contact $contact) { // } /** * Update the specified resource in storage. */ public function update(Request $request, Contact $contact) { // } /** * Remove the specified resource from storage. */ public function destroy(Contact $contact, $id) { try{ Contact::destroy($id); return response()->json([ 'message' => 'Berhasil hapus data', 'status' => true ]); }catch(\Exception $e){ return response()->json([ 'message' => 'Gagal hapus data, karena '.$e, 'status' => false ]); } } }