/** * 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 update($id) { if (Input::has('id')) { $writer = Writers::find(Input::get('id')); if (!$writer) { $writer = Writers::create(Input::only(['name', 'image', 'bio'])); } if (Input::hasFile('image')) { if (Request::file('image')->isValid()) { $writer->name = Input::get('name'); $writer->bio = Input::get('bio'); //dd(Input::hasFile('image')); $destination = public_path() . "/images/writers/"; $filename = Input::file('image')->getClientOriginalName(); //$upload_success = Filesystem::move($destinationPath, $filename); $upload_success = Request::file('image')->move($destination, $filename); $writer->image = $filename; } } $writer->save(); //return \View::make('admin.writers.show')->with(['status' => 'save_successful', 'writer' => $writer, 'writers'=>Writers::all(),'error'=>'none']); return Redirect::to('/admin/writers/' . $writer->id . '/show'); } else { return View::make('admin.writers.edit')->with(['status' => 'save_failed', 'writer' => Writers::find($id), 'writers' => Writers::all(), 'error' => 'Unable to save!']); } }