/** * Display Article * * Display a Single Article, category is specified * * @return Response */ public function show($category, $slug) { if (Input::has('selected_article')) { return Redirect::to('admin/articles/' . Input::get('selected_article') . '/'); } try { $article = Articles::where('slug', $slug)->first(); $author = Writers::where('id', 4); /*$article->author)->first(); */ if (!$author) { $author_name = "Unspecified Author"; } else { $author_name = $author->name; } //dd($author); //dd($article); return View::make('admin.articles.show', ['article' => $article, 'articles' => Articles::all(), 'author' => $author_name, 'error' => 'none']); } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) { //return "article (" . Input::get('selected_article') . " ) not found."; return View::make('admin.articles.show', ['article' => 'none', 'articles' => Articles::all(), 'author' => $author_name, 'error' => 'article not found']); } }
public function delete($id) { if (Input::has('selected_writer')) { return Redirect::to('admin/writers/' . Input::get('selected_writer') . '/delete'); } else { if (Input::has('confirmed_delete')) { try { //$writer = Writers::where('id', '=', $id)->get(); $writer = Writers::find($id); Writers::where('id', '=', $id)->delete(); return View::make('admin.writers.delete', ['status' => 'successful', 'writer' => $writer, 'writers' => Writers::all(), 'id' => $id]); } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) { return View::make('admin.writers.delete', ['status' => 'unsuccessful', 'writer' => $writer, 'writers' => Writers::all(), 'id' => $id]); } } else { $writer = Writers::find($id); return View::make('admin.writers.delete', ['status' => 'confirm', 'writer' => $writer, 'writers' => Writers::all(), 'id' => $id]); } } }