Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.86 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use App\Model\Balas;
  6. use App\Model\Pertanyaan;
  7. use Illuminate\Http\Request;
  8. use App\Http\Resources\BalasResource;
  9. use Symfony\Component\HttpFoundation\Response;
  10.  
  11.  
  12. class BalasController extends Controller
  13. {
  14.     /**
  15.      * Display a listing of the resource.
  16.      *
  17.      * @return \Illuminate\Http\Response
  18.      */
  19.     public function index(Pertanyaan $pertanyaan, Balas $balas)
  20.     {
  21.         // return $pertanyaan->balas;
  22.         return BalasResource::collection($pertanyaan->balas);
  23.     }
  24.  
  25.     /**
  26.      * Show the form for creating a new resource.
  27.      *
  28.      * @return \Illuminate\Http\Response
  29.      */
  30.     public function create()
  31.     {
  32.         //  
  33.     }
  34.  
  35.     /**
  36.      * Store a newly created resource in storage.
  37.      *
  38.      * @param  \Illuminate\Http\Request  $request
  39.      * @return \Illuminate\Http\Response
  40.      */
  41.     public function store(Pertanyaan $pertanyaan, Request $request)
  42.     {
  43.         $balas = $pertanyaan->balas()->create($request->all());
  44.         return response(['balas' => $balas], Response::HTTP_CREATED);
  45.     }
  46.  
  47.     /**
  48.      * Display the specified resource.
  49.      *
  50.      * @param  \App\Model\Balas $balas
  51.      * @return \Illuminate\Http\Response
  52.      */
  53.     public function show(Pertanyaan $pertanyaan, Balas $balas)
  54.     {
  55.         // return $balas;
  56.         return new BalasResource($balas);
  57.     }
  58.  
  59.     /**
  60.      * Update the specified resource in storage.
  61.      *
  62.      * @param  \Illuminate\Http\Request  $request
  63.      * @param  int  $id
  64.      * @return \Illuminate\Http\Response
  65.      */
  66.     public function update(Request $request, $id)
  67.     {
  68.         //
  69.     }
  70.  
  71.     /**
  72.      * Remove the specified resource from storage.
  73.      *
  74.      * @param  int  $id
  75.      * @return \Illuminate\Http\Response
  76.      */
  77.     public function destroy($id)
  78.     {
  79.         //
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement