/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker::Create(); $name = $faker->name; Eloquent::unguard(); Writers::create(['name' => $name, 'bio' => 'This is just a sample Writer. There is nothing to say here!', 'image' => '/images/writers/SampleWriter.jpg', 'slug' => str_replace(' ', '-', $name)]); }
public function index() { if (Auth::check()) { $bands = Bands::all(); $advertisers = Advertisers::all(); $writers = Writers::all(); $venues = Venues::all(); return View::make('admin.index', ['bands' => $bands, 'advertisers' => $advertisers, 'writers' => $writers, 'venues' => $venues]); } else { return Redirect::to('/admin/login'); } }
public function update($slug) { $success = true; $error = ""; $articles = Articles::all(); if (!$articles) { $articles = 'none'; } try { $article = Articles::where('slug', $slug)->first(); } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) { $success = false; $error = 'Unable to save this article: <br />' . $e->getMessage() . '). <br />'; } if ($success == true) { $article->title = Input::get('title'); $article->content = Input::get('content'); $article->month = Input::get('month'); $article->year = Input::get('year'); $article->author = Input::get('author'); $article->category = Input::get('category'); $article->update(); return Redirect::to('admin/articles/' . $slug . '/')->with(['article' => $article, 'articles', Articles::all()]); } else { return View::make('admin.articles.edit')->with(['id' => $article->id, 'status' => 'save_failed', 'article' => $article, 'author' => $author, 'articles' => $articles, 'writers' => Writers::all(), 'error' => $error]); } }
public function index() { return View::make('writers')->with('writers', Writers::all()); }
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]); } } }