/** * Run the database seeds. * * @return void */ public function run() { for ($i = 0; $i < 100; $i++) { DB::table('likes')->insert([['traveler' => rand(1, Traveler::count()), 'likes_journey' => rand(1, Journey::count()), 'created_at' => date('Y-m-d H:i:s', time()), 'updated_at' => date('Y-m-d H:i:s', time())]]); } }
/** * Update a journey post * * @return Illuminate\Http\Response */ protected function update() { $journey = Journey::where('uuid', '=', Input::get('post-uuid'))->first(); $journey->title = Input::get('title'); $journey->date = Input::get('date'); // Rewrite the contents of // the journeys' description $bodyFile = fopen(base_path() . '/public/assets/journeys/descriptions/' . $journey->description_filename, 'w+'); fwrite($bodyFile, htmlspecialchars(Input::get('body'))); fclose($bodyFile); // Rename the old image to indicate // it was deleted and save the new // one if there was a new image // uploaded if (Input::hasFile('header_image') && Input::file('header_image')->isValid()) { // There was a new image uploaded $oldHeaderImageFilename = $journey->header_image_filename; $headerImagePath = base_path() . '/public/assets/journeys/header_images/'; rename($headerImagePath . $oldHeaderImageFilename, $headerImagePath . '!' . $oldHeaderImageFilename); Input::file('header_image')->move($headerImagePath, $oldHeaderImageFilename); } // Remember the tags for it $this->persistTagsToJourneyWithID(Input::get('tags'), $journey->id); $journey->save(); return redirect('/journeys'); }