/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store() { $input = Request::all(); if (empty($input['alias'])) { $input['alias'] = genTopicAlias($input['name']); $data = Tour::where('alias', $input['alias'])->first(); if (!empty($data)) { $input['alias'] = create_permalink($input['alias']); } } else { $data = Tour::where('alias', $input['alias'])->first(); if (!empty($data)) { $input['alias'] = create_permalink($input['alias']); } } $photos = []; if (!empty($input['photo'])) { $temp = count($input['photo']); for ($i = 0; $i < $temp; $i++) { $photos[] = ['src' => $input['photo'][$i], 'title' => $input['title_img'][$i], 'desc' => $input['desc_img'][$i]]; } $input['photos'] = json_encode($photos); } $input['destinations'] = destination_encode($input['destinations']); Tour::create($input); return redirect()->action('Admin\\TourController@index'); }
/** * Run the database seeds. * * @return void */ public function run() { // We want to delete the comments table if it exists before running the seed DB::table('tours')->delete(); $tours = array(['category_id' => 1, 'user_id' => 1, 'title' => 'Tallinn Free Walking Tour', 'image' => 'img22.jpg', 'description' => 'There is a fun and inexpensive, yet very informative way to get to know Tallinn- join the Free Walking Tour. Great for people who dont mind sharing their tour experience with other fellow travelers.', 'likes' => 10], ['category_id' => 2, 'user_id' => 1, 'title' => 'Viru Bog and Kolga Manor Tour', 'image' => 'img22.jpg', 'description' => 'A visit to the Viru Bog has become a tradition, included in almost every tour operators excursion to Lahemaa. The Kolga Manor is a "fair" and authentic place, quite different from the dressy manors of Palmse or Vihula. Few dare to take their guests to the Kolga Manor.', 'likes' => 5], ['category_id' => 3, 'user_id' => 2, 'title' => 'A Day in Western Estonia', 'image' => 'img22.jpg', 'description' => 'Charming and historic Haapsalu with its Episcopal Castle, beach promenade, distinctive wooden houses and the White Lady. Meadows and beaches along with the refreshing sea to take a dip in. Castles with colourful histories and whatever is left of them.', 'likes' => 0], ['category_id' => 3, 'user_id' => 2, 'title' => 'A Day in Western Estonia', 'image' => 'img22.jpg', 'description' => 'Charming and historic Haapsalu with its Episcopal Castle, beach promenade, distinctive wooden houses and the White Lady. Meadows and beaches along with the refreshing sea to take a dip in. Castles with colourful histories and whatever is left of them.', 'likes' => 0], ['category_id' => 3, 'user_id' => 2, 'title' => 'A Day in Western Estonia', 'image' => 'img22.jpg', 'description' => 'Charming and historic Haapsalu with its Episcopal Castle, beach promenade, distinctive wooden houses and the White Lady. Meadows and beaches along with the refreshing sea to take a dip in. Castles with colourful histories and whatever is left of them.', 'likes' => 0], ['category_id' => 3, 'user_id' => 2, 'title' => 'A Day in Western Estonia', 'image' => 'img22.jpg', 'description' => 'Charming and historic Haapsalu with its Episcopal Castle, beach promenade, distinctive wooden houses and the White Lady. Meadows and beaches along with the refreshing sea to take a dip in. Castles with colourful histories and whatever is left of them.', 'likes' => 0], ['category_id' => 3, 'user_id' => 2, 'title' => 'A Day in Western Estonia', 'image' => 'img22.jpg', 'description' => 'Charming and historic Haapsalu with its Episcopal Castle, beach promenade, distinctive wooden houses and the White Lady. Meadows and beaches along with the refreshing sea to take a dip in. Castles with colourful histories and whatever is left of them.', 'likes' => 0]); foreach ($tours as $tour) { Tour::create($tour); } }
/** * * @param array $data * @return $tour */ public function createTour(array $data) { return Tour::create($data); }