本文整理匯總了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()]);
}