Skip to content

Instantly share code, notes, and snippets.

@sonichandni
Created May 3, 2023 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonichandni/b1a70415f40e4fd0298667184ff80204 to your computer and use it in GitHub Desktop.
Save sonichandni/b1a70415f40e4fd0298667184ff80204 to your computer and use it in GitHub Desktop.
Download user logo from user mobile number csv
public function test() {
$csv = \File::get(storage_path().'/app/public/mobile_data_id.csv');
$rows = str_getcsv($csv, "\n");
// Loop through each row
foreach ($rows as $mobileNumber) {
// Find user ID based on mobile number
$userId = \DB::table('client')->where('mobile', $mobileNumber)->value('id');
// Fetch logo image based on user ID TestLogoDir
$logoImage = \DB::table('user_biz')->where('user_id', $userId)->value('logo_img');
if(!empty($logoImage)) {
$url = CommonFunction::get_file_ad('public/flyer_image/business_logo', $logoImage);
// Download logo image
$path = "TestLogoDir/$mobileNumber/$logoImage";
Storage::disk('local')->put($path, file_get_contents($url));
} else {
echo '<pre>'; print_r($mobileNumber);
echo '<pre>'; print_r($userId);
}
}
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment