本文整理汇总了PHP中app\models\Post::getPublishedPosts方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::getPublishedPosts方法的具体用法?PHP Post::getPublishedPosts怎么用?PHP Post::getPublishedPosts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Post
的用法示例。
在下文中一共展示了Post::getPublishedPosts方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* 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]);
}
示例2: index
/**
* 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]);
}
示例3: published
public function published(Post $postModel)
{
$posts = $postModel->getPublishedPosts();
return view('post.index', ['posts' => $posts]);
}
示例4: actionIndex
/**
* Список постов.
* @return string
*/
public function actionIndex()
{
$post = new Post();
$category = new Category();
return $this->render('index', ['posts' => $post->getPublishedPosts(), 'categories' => $category->getCategories()]);
}