public function generateMarkerSlug() { $markers = Marker::all(); foreach ($markers as $marker) { $marker->slug = \Slug::make($marker->name); $marker->save(); } }
public function store() { if (!Request::input('marker_id')) { $newMarker = Marker::createNew(Request::all()); Request::merge(['marker_id' => (int) $newMarker->id]); return Location::createNew(Request::except('city', 'coordinates')); } return Location::createNew(Request::all()); }
public function run() { DB::table('markers')->delete(); DB::table('locations')->delete(); Marker::create(['id' => 1, 'coordinates' => "54.9769240537932, 73.39931488037111", 'city' => 'omsk']); Marker::create(['id' => 2, 'coordinates' => "54.975076807307914, 73.38135480880739", 'city' => 'omsk']); Location::create(['marker_id' => 1, 'name' => "testetst", 'address' => 'f', 'time' => '12', 'type' => "restaurant", 'description' => 'ff', 'price' => '5', 'specification' => "vegetarian", 'rating' => 2]); Location::create(['marker_id' => 1, 'name' => "edsve4wf", 'address' => 'f', 'time' => '45', 'type' => "cafe", 'description' => 'ff', 'price' => '5', 'specification' => "vegetarian", 'rating' => 4]); Location::create(['marker_id' => 2, 'name' => "dgsg", 'time' => '34', 'address' => 'f', 'type' => "coffee", 'description' => 'ff', 'price' => '5', 'specification' => "vegan", 'rating' => 5]); Location::create(['marker_id' => 2, 'address' => 'f', 'name' => "gmmgmm", 'time' => '12', 'type' => "restaurant", 'price' => '5', 'description' => 'ff', 'specification' => "vegetarian", 'rating' => 1]); Location::create(['marker_id' => 2, 'address' => 'f', 'name' => "345344fr", 'time' => '12', 'type' => "restaurant", 'price' => '5', 'description' => 'ff', 'specification' => "vegetarian", 'rating' => 4]); }
/** * Agregate meta description for view * * @param $metaOptions * @return string */ public static function getMetaDesc($metaOptions) { $mk = CmsOption::getValue('metadesc'); if (isset($metaOptions['marker'])) { $mk = $mk . ',' . $metaOptions['marker']->metadesc; } if (isset($metaOptions['recipie'])) { foreach ($metaOptions['recipie']->markers as $marker) { $mk = $mk . ',' . $marker->metadesk; } $mk = $mk . ',' . $metaOptions['recipie']->metadesc; } if (isset($metaOptions['filter'])) { foreach ($metaOptions['filter'] as $idMarker) { if ($idMarker > 0) { $marker = Marker::find($idMarker); if ($marker->metadesk != '') { $mk = $mk . ',' . $marker->metadesk; } } } } return $mk; }
public static function createNew($input) { $markerData = ['city' => $input['city'], 'coordinates' => $input['coordinates']]; return Marker::create($markerData); }
public function getMarker($id) { return Marker::wherePropositionId($id)->get()->first(); }
public function showRecipiesByMarkerBySlug($slug) { if ($marker = Marker::where('slug', '=', $slug)->first()) { $recipies = $marker->recipies; $recipies = $recipies->filter(function ($item) { return $item->postStatus_id == 3; }); $title = CmsOption::getValue('Название сайта') . ' | ' . $marker->name; $metaOptions = ['marker' => $marker]; Session::put('recipies', $recipies); Session::put('marker', $marker); Session::put('typepage', 'bymarker'); if ($marker->slug == '') { $markerslug = \Slug::make($marker->name); } else { $markerslug = $marker->slug; } return view('recipieGrid', ['recipies' => $recipies, 'title' => $title, 'page_title' => $marker->name, 'metaOptions' => $metaOptions]); } }