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


PHP Article::whereSlug方法代码示例

本文整理汇总了PHP中app\Article::whereSlug方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::whereSlug方法的具体用法?PHP Article::whereSlug怎么用?PHP Article::whereSlug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Article的用法示例。


在下文中一共展示了Article::whereSlug方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 public function store(Request $request, $slug)
 {
     $article = Article::whereSlug($slug)->firstOrFail();
     $comment = new Comment();
     $comment->article_id = $article->id;
     $comment->name = $request->get('name');
     $comment->comment = $request->get('comment');
     $comments = $article->comments();
     $comment->save();
     return redirect("/articles/{$slug}");
 }
开发者ID:bambangsusanto,项目名称:divkomapp,代码行数:11,代码来源:CommentsController.php

示例2: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     return Article::whereSlug($slug)->with('source.categories')->first();
 }
开发者ID:NewsRepost,项目名称:Fetcher,代码行数:10,代码来源:ArticleController.php

示例3: array

Route::get('/article/detail/{id}', array('uses' => 'ArticleController@showPublic'));
Route::get('/index', function () {
    $coupons = Coupon::all();
    return View::make('index')->with('coupons', $coupons);
});
Route::get('/admin', 'UserController@getAdminLogin');
Route::post('/admin', 'UserController@postAdminLogin');
Route::get('/logout', 'UserController@getLogout');
Route::get('/admin/dashboard', function () {
    return view('admin.content');
});
Route::model('articles', 'Article');
Route::model('merchants', 'Merchant');
Route::model('coupons', 'Coupon');
Route::model('categories', 'Category');
Route::bind('articles', function ($value, $route) {
    return App\Article::whereSlug($value)->first();
});
Route::bind('merchants', function ($value, $route) {
    return App\Merchant::whereSlug($value)->first();
});
Route::bind('coupons', function ($value, $route) {
    return App\Coupon::whereSlug($value)->first();
});
Route::bind('categories', function ($value, $route) {
    return App\Category::whereSlug($value)->first();
});
Route::resource('admin/article', 'ArticleController');
Route::resource('admin/merchant', 'MerchantController');
Route::resource('admin/coupon', 'CouponController');
Route::resource('admin/category', 'CategoryController');
开发者ID:sientong,项目名称:tagin,代码行数:31,代码来源:routes.php

示例4: update

 /**
  * Update the specified resource in storage.
  *
  * @param string $slug
  *
  * @return \Illuminate\Http\Response
  */
 public function update($slug)
 {
     $this->article = new Article($this->request);
     Helper::allow('article-edit', $this->article);
     $this->article->id = Article::whereSlug($slug)->pluck('id')->first();
     $this->article->updated_at = Carbon::now();
     $this->article->body = $this->_stripTags();
     $this->article->can_comment = isset($this->article->can_comment);
     $this->article->auto_comments = isset($this->article->auto_comments);
     $this->_putCategories();
     $this->article->url = $this->_articleUrl();
     DB::table('articles')->where('slug', $slug)->update($this->article->toArray());
     return redirect(route('articles.index'))->with('success', 'Your article "' . $this->article->title . '" has been successfully updated!');
 }
开发者ID:Dimimo,项目名称:Booklet,代码行数:21,代码来源:ArticlesController.php

示例5: tag

 public function tag($slug)
 {
     return Article::whereSlug($slug)->published()->firstOrFail()->tags()->get();
 }
开发者ID:amirmasoud,项目名称:chakoshLaravelBlog,代码行数:4,代码来源:TagHelper.php


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