1<?php namespace App\Http\Controllers;
2
3use App\Contact;
4use Illuminate\Http\Request;
5use Inertia\Inertia;
6
7class ContactController extends Controller
8{
9
10 public function index()
11 {
12 $data = Contact::all();
13 return Inertia::render('contacts/index', ['data' => $data]);
14 }
15
16 public function store(Request $request)
17 {
18 Contact::create($request->all());
19 return redirect()->back();
20 }
21
22 public function update(Request $request)
23 {
24 if ($request->has('id')) {
25 Contact::find($request->input('id'))->update($request->all());
26 return redirect()->back();
27 }
28 }
29
30 public function destroy(Request $request)
31 {
32 if ($request->has('id')) {
33 Contact::find($request->input('id'))->delete();
34 return redirect()->back();
35 }
36 }
37} Copied