Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Response;
- use App\Feedback;
- class ApiController extends Controller
- {
- public function index() {
- $data = Feedback::all();
- $response = [
- 'msg' => 'data berhasil dimuat',
- 'data' => $data
- ];
- return response()->json($response,201) ;
- }
- public function edit($id) {
- $data = Feedback::find($id);
- $response = [
- 'msg' => 'data enchant_broker_get_error(broker)hasil dimuat',
- 'data' => $data
- ];
- return response()->json($response,201) ;
- }
- public function store(Request $request)
- {
- Feedback::create([
- 'nama' => $request->nama,
- 'email' => $request->email,
- 'feedback' => $request->feedback,
- ]);
- $response = [
- 'msg' => 'Data feedback terbuat',
- 'data' => $request->all()
- ];
- return response()->json($response,201);
- }
- public function update(Request $request, $id)
- {
- $feed = Feedback::find($id);
- $feed->update($request->all());
- $response = [
- 'msg' => 'data berhasil di update',
- 'data'=> $request->all(),
- ];
- return response()->json($response,201);
- }
- public function destroy($id)
- {
- $feed = Feedback::find($id);
- $feed->delete();
- $response = [
- 'msg' => 'data berhasil di hapus',
- 'data'=> $feed
- ];
- return response()->json($response,201);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement