Ejemplo n.º 1
0
 /**
  * to show the seleted article
  * @return response
  */
 public function show($slug, Article $article, Category $category)
 {
     //ArticleController::timezone();
     $arti = $article->where('slug', $slug)->where('status', '1')->where('type', '1')->first();
     // dd($arti);
     //$categorys = $category->get();
     //$avatar->get('*****@*****.**');
     return view('themes.default1.client.kb.article-list.show', compact('arti'));
 }
 /**
  * Update an Artile by id
  * @param type Integer $id
  * @param type Article $article
  * @param type Relationship $relation
  * @param type ArticleRequest $request
  * @return Response
  */
 public function update($slug, Article $article, Relationship $relation, ArticleUpdate $request)
 {
     $aid = $article->where('id', $slug)->first();
     $id = $aid->id;
     $sl = $request->input('slug');
     $slug = str_slug($sl, "-");
     // dd($slug);
     $article->slug = $slug;
     /* get the attribute of relation table where id==$id */
     $relation = $relation->where('article_id', $id);
     $relation->delete();
     /* get the request of the current articles */
     $article = $article->whereId($id)->first();
     $requests = $request->input('category_id');
     $id = $article->id;
     foreach ($requests as $req) {
         DB::insert('insert into article_relationship (category_id, article_id) values (?,?)', [$req, $id]);
     }
     /* update the value to the table */
     if ($article->fill($request->all())->save()) {
         $article->slug = $slug;
         $article->save();
         return redirect('article')->with('success', 'Article Updated Successfully');
     } else {
         return redirect('article')->with('fails', 'Article Not Updated');
     }
 }