本文整理汇总了PHP中app\Post::published方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::published方法的具体用法?PHP Post::published怎么用?PHP Post::published使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Post
的用法示例。
在下文中一共展示了Post::published方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$jobs = Job::take(6)->get();
$posts = Post::published()->orderBy('created_at', 'desc')->where('category_id', '1')->get()->take(3);
$vignettes = Post::published()->orderBy('created_at', 'desc')->where('category_id', '1' and 'is_sticky', '0')->skip(3)->take(6)->get();
return view('pages.home.index', compact('jobs', 'posts', 'vignettes'));
}
示例2: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$post = Post::findOrFail($id);
$articles = Post::published()->get();
$user = Auth::user();
$post->load('user', 'comments');
return view('posts.post', compact('post', 'articles', 'user'));
}
示例3: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$posts_published = Post::published()->count();
$posts_editing = Post::where('published', 'uc')->count();
$posts_sticky = Post::where('is_sticky', 'on')->count();
$posts = Post::count();
$users = User::count();
$jobs = Job::count();
$questions = Question::count();
$categories = Category::count();
return view('admin.stats.index', compact('posts', 'posts_published', 'posts_sticky', 'posts_editing', 'users', 'jobs', 'questions', 'categories'));
}
示例4: index
public function index()
{
$parsedown = new \ParsedownExtra();
$config = Configuration::find(1);
$posts = Post::published()->orderBy('published_at', 'desc')->get();
$feed = new Feed();
$channel = new Channel();
$channel->title($config->blog_title)->description($config->blog_description)->url(url('/'))->appendTo($feed);
foreach ($posts as $post) {
$item = new Item();
$item->title($post->title)->description($parsedown->parse($post->content))->url(url("/articles/{$post->slug}"))->guid(url("/articles/{$post->slug}"), true)->appendTo($channel);
}
return response($feed)->header('Content-Type', 'application/rss+xml');
}
示例5: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
parent::boot($router);
$router->bind('posts', function ($id) {
return \App\Post::published()->findOrFail($id);
});
$router->bind('users', function ($id) {
return \App\User::findOrFail($id);
});
$router->bind('roles', function ($name) {
return \App\Role::where('role', $name)->firstOrFail();
});
$router->bind('comments', function ($id) {
return \App\Comment::findOrFail($id);
});
$router->bind('tags', function ($name) {
return \App\Tag::where('name', $name)->firstOrFail();
});
}
示例6: index
/**
* GET /posts
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index()
{
$posts = Post::published()->get();
return view('post.index', compact('posts'));
}
示例7: allArticlesUser
public function allArticlesUser($id)
{
$user = User::findOrFail($id);
$vignettes = Post::published()->where('user_id', $user->id)->where('category_id', '1')->orderBy('created_at', 'desc')->get();
return view('pages.blog.all-articles-user', compact('user', 'vignettes'));
}
示例8: showPost
/**
* @return the selected post
* @param $id
* @param string $slug
*/
public function showPost($id, $slug = '')
{
$post = Post::published($id)->first();
$comments = Comment::commentPublished($post->id)->get();
return view('front.single', compact('post', 'comments'));
}
示例9: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$configuration = Configuration::find(1);
$posts = Post::published()->orderBy('published_at', 'desc')->simplePaginate(5);
return view('posts/index', ['posts' => $posts, 'configuration' => $configuration]);
}