当前位置: 首页>>代码示例>>PHP>>正文


PHP Post::whereSlug方法代码示例

本文整理汇总了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'));
 }
开发者ID:aabraham88,项目名称:blog,代码行数:13,代码来源:BlogController.php

示例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);
 }
开发者ID:boosb,项目名称:test,代码行数:7,代码来源:BlogController.php

示例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);
 }
开发者ID:stephanjusypiw,项目名称:l5beauty,代码行数:8,代码来源:BlogController.php

示例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'));
 }
开发者ID:edom-huang,项目名称:myBlog,代码行数:9,代码来源:BlogController.php

示例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);
 }
开发者ID:stretch0,项目名称:homework,代码行数:17,代码来源:RedirectIfNotAuthor.php

示例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);
 }
开发者ID:shempignon,项目名称:laravel-5-blog-mvc,代码行数:20,代码来源:RouteServiceProvider.php

示例7: editPost

 public function editPost($slug)
 {
     $post = Post::whereSlug($slug)->firstOrFail();
     return View('blog.edit')->with('title', '編輯文章')->with('post', $post);
 }
开发者ID:fufukwang,项目名称:blog_test,代码行数:5,代码来源:BlogController.php

示例8: getPost

 public function getPost($slug)
 {
     $post = Post::whereSlug($slug)->firstOrFail();
     return view('blog.post')->with(['post' => $post]);
 }
开发者ID:mastashake08,项目名称:jyroneparker,代码行数:5,代码来源:PostController.php

示例9: showPost

 public function showPost($slug)
 {
     $post = Post::whereSlug($slug)->firstOrFail();
     return view('blog.post')->withPost($post);
 }
开发者ID:andela-sakande,项目名称:l5beauty,代码行数:5,代码来源:BlogController.php

示例10: showPost

 public function showPost($slug)
 {
     $post = Post::whereSlug($slug)->with('author')->first();
     return view('pages.post', compact('post'));
 }
开发者ID:scotch-io,项目名称:laravel-cashier-course,代码行数:5,代码来源:SiteController.php

示例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);
 }
开发者ID:phoenix1331,项目名称:astura,代码行数:11,代码来源:PostsController.php

示例12: showPost

 public function showPost($year, $month, $day, $slug)
 {
     $post = Post::whereSlug($slug)->firstOrFail();
     return view('posts.show')->withPost($post);
 }
开发者ID:ronaldrosales,项目名称:e74,代码行数:5,代码来源:PostsController.php

示例13: showPost

 public function showPost($slug)
 {
     $post = Post::whereSlug($slug)->firstOrFail();
     return view('blog.post', ['post' => $post]);
 }
开发者ID:visor86,项目名称:blogs,代码行数:5,代码来源:BlogController.php

示例14: destroy

 public function destroy(Post $post, $slug)
 {
     $post = Post::whereSlug($slug)->firstOrFail();
     $post->delete();
     return redirect('blog');
 }
开发者ID:lomholdt,项目名称:lomholdt.com,代码行数:6,代码来源:PostsController.php


注:本文中的app\Post::whereSlug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。