Example #1
0
 public function storesub(SubFormRequest $request)
 {
     $sub = new Sub();
     $sub->name = $request->get('name');
     $sub->owner_id = \Auth::id();
     $sub->save();
     return \Redirect::to('r/' . $request->get('name'));
 }
Example #2
0
 public function storepost(PostFormRequest $request)
 {
     $post = new Post();
     $post->title = $request->get('title');
     $post->url = $request->get('url');
     $post->sub_id = Sub::where('name', $request->get('sub'))->first()->id;
     $post->user_id = \Auth::id();
     $post->save();
     return \Redirect::to('/');
 }
 /**
  * Display the specified resource.
  *
  * @param  String $subname
  * @param int $postId
  * @return Response
  */
 public function show($subname, $postId)
 {
     $sub = Sub::where('name', $subname)->firstOrFail();
     $post = Post::find($postId);
     return view('post')->with('title', $post->title)->with('sub', $post->sub()->name)->with('post', $post);
 }
 /**
  * Display the specified resource.
  *
  * @param  string  $name
  * @return Response
  */
 public function show($name)
 {
     //will return view that shows sub info
     $sub = Sub::where('name', $name)->firstOrFail();
     return view('sub')->with('sub', $sub->name)->with('posts', $sub->posts()->paginate(15));
 }