public function search(Request $request) { $q = $request->get('q'); $posts = Post::orWhere('title', 'like', '%' . $q . '%')->orWhere('content', 'like', '%' . $q . '%')->get(); $locations = Location::orWhere('name', 'like', '%' . $q . '%')->orWhere('address', 'like', '%' . $q . '%')->get(); return view('admin.admin.search', compact('posts', 'locations')); }
public function googleMaps(Location $location) { if ((empty($location->google_maps_base64) || empty($location->google_maps_type)) && !empty($location->latitude) && !empty($location->longitude)) { $image_path = 'https://maps.googleapis.com/maps/api/staticmap?'; $image_path .= 'center=' . $location->latitude . ',' . $location->longitude; $image_path .= '&zoom=16'; $image_path .= '&size=300x300'; $image_path .= '&maptype=roadmap'; $image_path .= '&markers=color:red%7Clabel:' . $location->id . '%7C' . $location->latitude . ',' . $location->longitude; $image_path .= '&language=iw'; $image_path .= '&key=AIzaSyCcIcPu2LwdIgraVp4WrXhjGanyySaj72A'; $image = file_get_contents($image_path); $type = getimagesize($image_path)['mime']; $base64 = base64_encode($image); $location->update(['google_maps_base64' => $base64, 'google_maps_type' => $type]); } }
public function edit(Post $post) { $images = Image::latest()->take(10)->get(); $locations = Location::latest()->take(10)->get(); return View('admin.posts.edit', compact('post', 'images', 'locations')); }
public function blog() { $posts = Post::latest('published_at')->published()->get(); $locations = Location::latest()->take(10)->get(); return View('posts.blog', compact('posts', 'locations')); }