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}");
 }
Example #2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($slug)
 {
     return Article::whereSlug($slug)->with('source.categories')->first();
 }
Example #3
0
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');
Example #4
0
 /**
  * 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!');
 }
 public function tag($slug)
 {
     return Article::whereSlug($slug)->published()->firstOrFail()->tags()->get();
 }