本文整理汇总了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}");
}
示例2: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($slug)
{
return Article::whereSlug($slug)->with('source.categories')->first();
}
示例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');
示例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!');
}
示例5: tag
public function tag($slug)
{
return Article::whereSlug($slug)->published()->firstOrFail()->tags()->get();
}