コード例 #1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $editor = \Auth::user()->id;
     $author = Story::where('id', $id)->pluck('user_id');
     if ($author == $editor) {
         $state = 'on';
         $story = Story::find($id);
         $parts = part::where('story_id', $id)->get();
         $author = user::where('id', $editor)->get()->first();
         return view('story.edit', compact('story', 'state', 'parts', 'author'));
     } else {
         return redirect('story/' . $id);
     }
 }