當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Article::published方法代碼示例

本文整理匯總了PHP中app\Article::published方法的典型用法代碼示例。如果您正苦於以下問題:PHP Article::published方法的具體用法?PHP Article::published怎麽用?PHP Article::published使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Article的用法示例。


在下文中一共展示了Article::published方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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('articles', function ($id) {
         return Article::published()->findOrFail($id);
     });
 }
開發者ID:mathewsandi,項目名稱:Sezgi,代碼行數:13,代碼來源:RouteServiceProvider.php

示例2: 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('articles', function ($id) {
         $article = Article::findOrFail($id);
         // If the owner return all articles else return only published.
         if (Auth::user() && $article->user_id === Auth::user()->id) {
             $articles = Article::findOrFail($id);
         } else {
             $articles = Article::published()->findOrFail($id);
         }
         return $articles;
     });
     $router->bind('questions', function ($id) {
         return Question::findOrFail($id);
     });
     $router->bind('answers', function ($id) {
         return Answer::findOrFail($id);
     });
     $router->bind('tags', function ($name) {
         return Tag::where('name', $name)->firstOrFail();
     });
     $router->bind('users', function ($id) {
         return User::findOrFail($id);
     });
 }
開發者ID:nilstr,項目名稱:stackoverflow-clone,代碼行數:33,代碼來源:RouteServiceProvider.php

示例3: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     /**
      * Binding the model
      */
     // $router->model('articles', 'App\Article');
     /**
      * Optional custom bind
      */
     $router->bind('articles', function ($id) {
         /**
          * Show only the published articles
          */
         return \App\Article::published()->findOrFail($id);
     });
     // $router->model('tags', 'App\Tag');
     $router->bind('tags', function ($name) {
         /**
          * Show only the related same tag by name
          */
         return \App\Tag::where('name', $name)->firstOrFail();
     });
 }
開發者ID:rudbast,項目名稱:laravel-tutorial,代碼行數:31,代碼來源:RouteServiceProvider.php

示例4: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     /*Route::model*/
     /**
      * Route model binding altering default logic
      * $router->bind('articles',function($id){
      *     return \App\Article::published()->findOrFail($id);
      * });
      */
     /*Using wildcard*/
     /*$router->model('articles','App\Article');*/
     $router->bind('articles', function ($id) {
         return \App\Article::published()->findOrFail($id);
     });
     $router->bind('rates', function ($id) {
         return \App\Rate::where('id', $id)->firstOrFail();
     });
     $router->bind('customers', function ($id) {
         return \App\Customer::where('id', $id)->firstOrFail();
     });
     $router->bind('tags', function ($name) {
         return \App\Tag::where('name', $name)->firstOrFail();
     });
     $router->bind('motherboards', function ($name) {
         return \App\Motherboard::where('name', $name)->firstOrFail();
     });
 }
開發者ID:sephestrito,項目名稱:learning-laravel-5,代碼行數:35,代碼來源:RouteServiceProvider.php

示例5: getCoursesInCategory

 public function getCoursesInCategory($slug)
 {
     $articles = Article::published()->orderBy('published_at', 'desc')->take(2)->get();
     $category = Category::where('slug', $slug)->first();
     $courses = Course::published()->where('category_id', $category->id)->get();
     return view('courses.index', ['courses' => $courses, 'page_id' => $slug, 'category' => $category, 'latest_articles' => $articles]);
 }
開發者ID:dadigu,項目名稱:haskolabru,代碼行數:7,代碼來源:CoursesController.php

示例6: show

 public function show($slug)
 {
     $page = Page::where('slug', $slug)->first();
     $courses = Course::published()->hasCategory()->orderBy('created_at', 'desc')->take(4)->get();
     $articles = Article::published()->orderBy('published_at', 'desc')->take(2)->get();
     return view('pages.show', ['page' => $page, 'latest_courses' => $courses, 'latest_articles' => $articles]);
 }
開發者ID:dadigu,項目名稱:haskolabru,代碼行數:7,代碼來源:PagesController.php

示例7: 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('articles', function ($id) {
         return \App\Article::published()->findOrFail($id);
     });
     $router->model('articles', 'App\\Article');
 }
開發者ID:beitsafeshuai,項目名稱:Laravel,代碼行數:15,代碼來源:RouteServiceProvider.php

示例8: 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('articles', function ($id) {
         return \Route::currentRouteName() == "articles.edit" ? \App\Article::findOrFail($id) : \App\Article::published()->findOrFail($id);
     });
     $router->bind('tags', function ($name) {
         return \App\Tag::where('name', $name)->firstOrFail();
     });
 }
開發者ID:redshot,項目名稱:learning-laravel-5,代碼行數:16,代碼來源:RouteServiceProvider.php

示例9: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('articles', function ($id) {
         return Article::published()->findOrFail($id);
     });
     $router->bind('tags', function ($tags) {
         return Tag::where('name', $tags)->first();
     });
     parent::boot($router);
 }
開發者ID:rkang30,項目名稱:newdev_L5.1,代碼行數:16,代碼來源:RouteServiceProvider.php

示例10: 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('articles', function ($id) {
         return \App\Article::published()->findOrFail($id);
     });
     $router->bind('tags', function ($name) {
         return \App\tag::where('name', $name)->firstOrFail();
     });
 }
開發者ID:GanjaGanja,項目名稱:laravel-5-fundamentals,代碼行數:16,代碼來源:RouteServiceProvider.php

示例11: edit

 public function edit($id)
 {
     if (Auth::user()->name === 'Penna') {
         $article = Article::published()->findOrFail($id);
         if (Auth::user()->id == $article->user_id) {
             return view('edit', compact('article'));
         } else {
             return redirect('/');
         }
     }
 }
開發者ID:mathewsandi,項目名稱:PennasSite,代碼行數:11,代碼來源:ArticleController.php

示例12: 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->model('articles', 'App\Article');
     //\Illuminate\Support\Facades\Route::model('articles', 'App\Article');
     $router->bind('articles', function ($id) {
         return \App\Article::published()->findOrFail($id);
         //return \App\Article::findOrFail($id);
     });
 }
開發者ID:kian-barba,項目名稱:learning-laravel5-Kian,代碼行數:17,代碼來源:RouteServiceProvider.php

示例13: composeSidebar

 private function composeSidebar()
 {
     view()->composer('blog.partials.side', function ($view) {
         $allCategories = \App\Category::getSortedCategories();
         $NewestArticles = \App\Article::published()->orderBy('updated_at', 'desc')->take(10)->get();
         $view->with(compact('allCategories', 'NewestArticles'));
     });
     view()->composer('home.partials.side', function ($view) {
         $NewestArticles = \App\Article::published()->orderBy('updated_at', 'desc')->take(10)->get();
         $view->with(compact('NewestArticles'));
     });
 }
開發者ID:ambarsetyawan,項目名稱:laravel5-blog-1,代碼行數:12,代碼來源:ViewComposerServiceProvider.php

示例14: 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->model('articles', 'App\Article');
     /**
      *Tuong tu cho ham ben tren
      */
     $router->bind('articles', function ($id) {
         return \App\Article::published()->findOrFail($id);
     });
     $router->bind('tag', function ($name) {
         return \App\Tag::where('name', $name)->firstOrFail();
     });
 }
開發者ID:nagaokashi,項目名稱:Laravel-5.1-example,代碼行數:20,代碼來源:RouteServiceProvider.php

示例15: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     /**
      * Bind the wildcard 'articles' with the model App\Article for use in Route Model Binding.
      */
     //$router->model('articles', 'App\Article');
     $router->bind('articles', function ($id) {
         return \App\Article::published()->findOrFail($id);
     });
     $router->bind('tags', function ($name) {
         return \App\Tag::where('name', $name)->firstOrFail();
     });
 }
開發者ID:leonardoapolinario,項目名稱:laravel5,代碼行數:20,代碼來源:RouteServiceProvider.php


注:本文中的app\Article::published方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。