本文整理汇总了PHP中app\Post::whereSlug方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::whereSlug方法的具体用法?PHP Post::whereSlug怎么用?PHP Post::whereSlug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Post
的用法示例。
在下文中一共展示了Post::whereSlug方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($slug)
{
//Muestra un post
$post = Post::whereSlug($slug)->firstOrFail();
$comments = $post->comments()->get();
return view('blog.show', compact('post', 'comments'));
}
示例2: showPost
public function showPost($slug)
{
$post = Post::whereSlug($slug)->firstOrFail();
$discuss = Discuss::where('post_id', '=', $post->id)->orderBy('dis_date', 'desc')->paginate(config('blog.posts_per_page'));
//dd($discuss->all(),$post->all());
return view('blog.post', compact('discuss'))->withPost($post);
}
示例3: showPost
public function showPost($slug)
{
/* Adding a dynamic 'where' to your Eloquent query
whereSlug() is the same as -> Results in ...WHERE `slug` = 'slug'...
*/
$post = Post::whereSlug($slug)->firstOrFail();
return view('blog.post')->withPost($post);
}
示例4: showPost
public function showPost($slug, request $request)
{
$post = Post::whereSlug($slug)->firstOrFail();
$tag = $request->get('tag');
if ($tag) {
$tag = Tag::whereTag($tag)->firstOrFail();
}
return view($post->layout, compact('post', 'tag', 'slug'));
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// echo '<pre>';
// print_r( Post::whereSlug( $request->slug ) );
// echo '</pre>';
if (!$request->user()->id == Post::whereSlug($request->slug)->user->id) {
return redirect('/forum');
}
return $next($request);
}
示例6: boot
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
// Route Bindings
$router->bind('categories', function ($value) {
return Category::whereSlug($value)->first();
});
$router->bind('posts', function ($value) {
return Post::whereSlug($value)->first();
});
$router->bind('author', function ($value) {
return User::whereName($value)->first();
});
parent::boot($router);
}
示例7: editPost
public function editPost($slug)
{
$post = Post::whereSlug($slug)->firstOrFail();
return View('blog.edit')->with('title', '編輯文章')->with('post', $post);
}
示例8: getPost
public function getPost($slug)
{
$post = Post::whereSlug($slug)->firstOrFail();
return view('blog.post')->with(['post' => $post]);
}
示例9: showPost
public function showPost($slug)
{
$post = Post::whereSlug($slug)->firstOrFail();
return view('blog.post')->withPost($post);
}
示例10: showPost
public function showPost($slug)
{
$post = Post::whereSlug($slug)->with('author')->first();
return view('pages.post', compact('post'));
}
示例11: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($value)
{
$post = Post::whereSlug($value)->first();
return view('blog.show', compact('post'))->with('title', $post->name);
}
示例12: showPost
public function showPost($year, $month, $day, $slug)
{
$post = Post::whereSlug($slug)->firstOrFail();
return view('posts.show')->withPost($post);
}
示例13: showPost
public function showPost($slug)
{
$post = Post::whereSlug($slug)->firstOrFail();
return view('blog.post', ['post' => $post]);
}
示例14: destroy
public function destroy(Post $post, $slug)
{
$post = Post::whereSlug($slug)->firstOrFail();
$post->delete();
return redirect('blog');
}