當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。