/** * Display a listing of the resource. * * @return Response */ public function index(Post $postModel) { //$posts = Post::all(); //dd($posts); //$posts = Post::latest('published_at')->where('published_at','<=',Carbon::now())->get(); $posts = $postModel->getPublishedPosts(); return view('post.index', ['posts' => $posts]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Post $postModel, Images $imgModel) { //$posts = Post::all(); //$posts = Post::latest('published_at')->get(); //$user_id = session('id'); //dd($tt); $posts = $postModel->getPublishedPosts(); foreach ($posts as $key => $value) { $img = $imgModel->getLastPostImg($value['id']); $name = ''; if (isset($img[0])) { $name = $img[0]['name']; } $posts[$key]['img'] = $name; } //dd($posts); $user_id = session('id'); return view('post.index', ['posts' => $posts, 'user_id' => $user_id]); }
public function published(Post $postModel) { $posts = $postModel->getPublishedPosts(); return view('post.index', ['posts' => $posts]); }
/** * Список постов. * @return string */ public function actionIndex() { $post = new Post(); $category = new Category(); return $this->render('index', ['posts' => $post->getPublishedPosts(), 'categories' => $category->getCategories()]); }