Get latitude and longitude given name and address - google-places-api

I have a CSV file with name,area,city fieds and I'm expecting that CSV with following fields name,area,city,latitude,longitude
Can any one suggest which API is best for these,
I already tried
Google API's
Textsearch: this is giving overall city wise. Not particular
eg: kfc, in jp nagar 1st phase, bangalore it throws all over bangalore kfc list
I want exactly
echo $url = "https://maps.googleapis.com/maps/api/geocode/json?address=" . $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key;
Which API will fulfill my requirement?
I tried this also
$url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=". $name1 . "+" . $area1 . "+" . $city . "&key=" . $api_key;

Related

Convert Query from Codeigniter to Laravel 8

How to write this query in laravel? this query was used in Codeigniter
$ci->db->query("SELECT ratings.rating_id," . $table . "." . $namefield . " as thenamefield,ROUND(AVG(ratings.rating_num),2) as rating
FROM ratings," . $table . " WHERE " . $table . "." . $idfield . " = ratings.rating_id GROUP BY rating_id
ORDER BY rating DESC LIMIT " . $limit . "");
try this
$select_part = $table . "." . $namefield;
DB::table('ratings')
->select('ratings.rating_id',DB::raw("{$select_part} as thenamefield"),DB::raw("ROUND(AVG(ratings.rating_num)2) as rating"))
->crossJoin($table)
->whereRaw("{$select_part} = ratings.rating_id")
->groupBy("rating_id")
->orderByRaw("rating DESC")
->limit($limit)
->get();

Excel file with Multiple Sheets in Laravel-Excel 3.1 -> Import Original and Store + Store Individual sheets after cell validations

Thanks for the reaching out to my question, but i have got a problem, I'm trying to Import an excel file with multiple sheets.
Find sheets by some cell-value validation, like if on cell E7, i have a value, store this sheet as separate file. I'm doing mapping() for cell values, and then trying to use Excel::store to save each individual sheet separately. Can't receive any data for individual sheets
Also store the original file. This works!
The issue is, i can't receive any data for storing individual-sheets as excel files, i can create the individual excel files, but no data is being received, or maybe i'm not using the right data-format mentioned on documentation.
Please also check the code. Any help would be appreciated.
public function mapping(): array
{
return [
'altafit_id' => 'E7',
'year' => 'B3',
'initial_month' => 'B4',
'final_month' => 'B5',
];
}
public function model(array $row)
{
// dd($row);
$name = $row['altafit_id'];
$year = $row['year'];
$initial_month = $row['initial_month'];
$final_month = $row['final_month'];
$file_type = 'club';
// dd(collect((object) $row));
Excel::store(collect((object) $row), 'P&L_' . $name . '_' . $year . '_' . $initial_month . '_06' . ',clubs' . ',' . $initial_month . ',' . $final_month . '.' . 'xls', 'public');
return new Files([
//'user_id' => $row['user_id'],
'file_name' => 'P&L_' . $name . '_' . $year . '_' . $initial_month . '_06' . ',clubs' . ',' . $initial_month . ',' . $final_month . '.' . 'xls',
'file_type' => $file_type
]);
}
Already check the documentation, but doesn't work for me.
https://docs.laravel-excel.com/3.1/getting-started/

laravel database model "with" function

I'm new in Laravel please me.
I'm working on laravel project which is already done by other developers.
I am stuck in Model::with function.
QxAppDetail::with(['qx_app_translation', 'qx_app_pages.qx_page_translation',
'user_app_info' => function($query) use($device_registration_id) {
$query->where('device_registration_id', $device_registration_id);
}])->selectRaw($this->table . '.app_id, '
. 'if(qx_app_details.app_icon = "", "", CONCAT("' . $this->app_icon_path . '","/", qx_app_details.app_icon)) as app_icon, '
. 'if(qx_app_details.download_link="","",CONCAT("' . $apk_url . '",qx_app_details.download_link)) as download_link,'
. $this->table . '.open_link, qx_app_details.package_name, qx_app_details.qeexo_default_app, qx_app_details.service_id,qx_app_details.sort_order,qx_app_details.is_enabled')
->orderBy('qx_app_details.sort_order', 'ASC')
->whereIn('qx_app_details.device_registration_id', array(0, $device_registration_id))
->get();
in above query i need to concat url with column like
'if(qx_app_details.download_link="","",CONCAT("' . $apk_url . '",qx_app_details.download_link)) as download_link,'
in qx_app_pages. but i'm not able to do this.
qx_app_pages and qx_page_translation are tables
Current Query output is:
[{"app_id":472,"app_icon":"","download_link":"","open_link":"","package_name":"com.android.settings","qeexo_default_app":"0","service_id":"9","sort_order":"0","is_enabled":"1","qx_app_translation":[{"locale":"en_US","app_name":"Settings","app_description":""}],"qx_app_pages":[{"page_id":213,"page_icon":"iVBORw0KGgoAAAANSUhEUgAAAGYAAABmCAMAAAAOARRQAAAApVBMV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99ZSMJWYnEObcHS1srlzoae3ExyJxGfMb\nHqeHKlR7NdbsYlljPWMjfsPjOHgv5F7NGSxnbiras3H2qXomP7M1cumeQY1zYX6jn7XWszx34XKe\nOqroz9N4zV7fFxCXiXSGnizGMmbwm4FTfVPmVi55eXsXKSqw30SK38jnk1OjrZ8Ll5zkzaFW14ub\n36h7+s2f33OVS\/v9TeEfl2vt3lUuZr+RZkMavPzZF9I3K8z3STm5P210Dlo8+A3kBEIGcb15bX6V\nBclpq7JqXpS\/JrPFpgY4aDGG\/Mb8pHd6Wj7fNs3b29vH\/fK06XsZ4ZLEsN\/EsfysgsbC9Xr6JD2u\nVq+zWPQXFMPP07D1DSP+CkvkHicYg28lyG9HqW9LjcVoJL6iV\/XzQnzZXRji7q+U98k+Fav9aSrQ\nu3NIeXduNPbMcf\/rL31v8D+2OXl\/9El2FQAAAABJRU5ErkJggg==","action":"com.android.settings","app_id":"472","qeexo_default_page":"0","is_deleted":"0","qx_page_translation":[{"page_name":"Home","locale":"en_US"}]}],"user_app_info":{"order_id":391,"device_registration_id":"11862","app_id":"472","default_page_id":"213","sort_order":"0","qeexo_default_app":"1","is_enabled":"1"}}]
Thanks in advance.

How to create a signed url with Firebase/JWT?

In the new version of Googles PHP-API-Cient the Google_Signer_P12 class was removed and now you should create signed urls via Firebase JWT (see https://github.com/google/google-api-php-client/blob/master/UPGRADING.md).
Unfortunately this doesn't work for me (I am trying to generate signed urls for cloud storage downloads). My previous (working) code looked like this:
$signer = new \Google_Signer_P12( 'privatekey.p12' , 'notasecret' );
$stringToSign = 'GET' . "\n" . "\n" . "\n" . $expires . "\n". '/' . $bucketName . '/' . $fileName;
$signature = $signer->sign( utf8_encode( $stringToSign ) );
$finalSignature = \Google_Utils::urlSafeB64Encode( $signature );
I tried to replace this with:
$stringToSign = 'GET' . "\n" . "\n" . "\n" . $expires . "\n". '/' . $bucketName . '/' . $fileName;
$finalSignature = \JWT::encode(
$stringToSign,
'privateKey.p12'
);
but I receive a "SignatureDoesNotMatch" error. Unfortunately I couldn't find anything in the docs on how to upgrade this part of the code.

Magento add category description in top navigation dropdown

I'm having problem in adding category description to top navigation. I'm using custom extension magento extension (got it from http://web-experiment.info/webandpeople-custom-menu-extension.html)
So far i went to navigation.php file and changed
$html.= '<a class="itemMenuName level' . $level . $active . '" href="' . $this->getCategoryUrl($child) . '"><span>' . $name . ' </span></a>' ;
To
$html.= '<a class="itemMenuName level' . $level . $active . '" href="' . $this->getCategoryUrl($child) . '"><span>' . $name . $description . ' </span></a>' ;
but still i'm getting only category name.
You can get the complete code in http://puck.ro/Navigation.txt
I thought this is not the right way of doing this!!
Did anyone tell me the exact way of doing this?
Thanks in advance.
I used this to grab the descriptions
$category_data =Mage::getModel('catalog/category')->load($id);
$category_data_des = $category_data->getDescription();
then just added in the loop like so
$html[] = '<span>'.$category_data_des.'</span>';

Resources