Exemple #1
0
 /**
  * Get all resources and paginate the result by given $perPage.
  *
  * @param int $perPage
  * @return mixed
  */
 public function allPaginated($perPage = 10)
 {
     return $this->article->paginate($perPage);
 }
Exemple #2
0
 /**
  * Show article.
  *
  * @param int $id
  *
  * @return mixed
  */
 public function showArticle($id)
 {
     try {
         $post = Article::with('user', 'category')->whereId(intval($id))->orWhere('slug', $id)->firstOrFail();
         $view = \Config::get('admin.views.post');
         return \View::make($view, compact('post'));
     } catch (ModelNotFoundException $e) {
         return \App::abort(404);
     }
 }
Exemple #3
0
 public function setMain($id)
 {
     $image = Model::where('id', '=', $id)->firstOrFail();
     Model::where('post_id', '=', $image->post_id)->update(['main' => 0]);
     $article = Article::where('id', '=', $image->post_id)->firstOrFail();
     $image->main = 1;
     $image->save();
     $article->image = $image->url;
     $article->save();
 }