public function getIndex() { $user = Auth::user(); $posts = Post::orderBy('updated_at', 'DESC')->get(); // Hier später definieren, welche Posts gelesen werden dürfen return view('posts.index')->with('posts', $posts); }
public function showList() { $count = Post::count(); $posts = Post::orderBy('created_at', 'DESC')->take(6)->get(); return view('list', ['count' => $count, 'posts' => $posts]); //будет использоваться list.blade.php }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $search_term = $request->input('search') ? $request->input('search') : ''; $limit = $request->input('limit') ? $request->input('limit') : 10; if ($search_term) { $posts = Post::orderBy('id', 'DESC')->where('post', 'LIKE', "%{$search_term}%")->orWhere('title', 'LIKE', "%{$search_term}%")->with(array('User' => function ($query) { $query->select('id', 'name'); }))->select('id', 'title', 'post', 'user_id')->paginate($limit); $posts->appends(array('search' => $search_term, 'limit' => $limit)); } else { $posts = Post::orderBy('id', 'DESC')->with(array('User' => function ($query) { $query->select('id', 'name'); }))->select('id', 'title', 'post', 'user_id')->paginate($limit); $posts->appends(array('limit' => $limit)); } if (!$posts) { return response()->json(['error' => ['message' => 'posts does not exist']], 404); } return response()->json(['data' => $this->transformCollection($posts)], 200)->setCallback($request->input('callback')); }
/** * Display a listing of the Post. * GET|HEAD /posts * * @return Response */ public function index(Request $request) { $offset = $request->page ? $request->page : 1; $limit = $request->limit ? $request->limit : 12; $category = $request->category; $isAllow = $request->isAllow ? $request->isAllow : ''; $offset = ($offset - 1) * $limit; if ($category) { if ($isAllow && $isAllow != '') { $posts = Post::where('isAllow', $isAllow)->where('category_id', $category)->orderBy('id', 'desc')->offset($offset)->limit($limit)->get(); } else { $posts = Post::where('category_id', $category)->orderBy('id', 'desc')->offset($offset)->limit($limit)->get(); } } else { if ($isAllow && $isAllow != '') { $posts = Post::where('isAllow', $isAllow)->orderBy('created_at', 'desc')->offset($offset)->limit($limit)->get(); } else { $posts = Post::orderBy('created_at', 'desc')->offset($offset)->limit($limit)->get(); } } return response()->json($posts); }
public function getHotPost() { return Post::orderBy('votes', 'desc')->get(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $posts = Post::orderBy('seen', 'asc')->orderBy('created_at', 'desc')->paginate($this->itemPerPage); return view('redac.posts.index', compact('posts')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $posts = Post::orderBy('created_at', 'desc')->simplePaginate(10); return view('web.post.index', ['posts' => $posts]); }
public function getLastPosts() { return Post::orderBy("created_at", "DESC")->get(); }