当前位置: 首页>>代码示例>>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;未经允许,请勿转载。