/** * used to get story for stats section * @return [type] [description] */ public function getStats() { $stories = Story::where('user_id', Auth::user()->id)->where('status', 'published')->get(); return $stories; }
public function index() { $stories = Story::where('published', 1)->get(); return view('stories', ['stories' => $stories]); }
/** * 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); } }
public function myStories() { $stories = Story::where("user_id", "=", Auth::user()->id)->orderBy('id', 'DESC')->get(); if (!$stories->isEmpty()) { return view('story.my_stories', compact('stories')); } else { flash()->warning('You have not created stories yet!'); return redirect('/'); } }
/** * Show the form for creating a new resource. * * @return Response */ public function create($id) { $story = Story::where('id', '=', $id)->first(); return view('chapter.create', compact('story')); }