Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (7) | Download .zip | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 32 | All time: 10,957 This week: 96 |
Version | License | PHP version | Categories | |||
saudiaddress 1.0 | Custom (specified... | 5 | PHP 5, Web services, Geography |
Description | Author | |
This package is specific mainly for applications used in Saudi Arabia .
This package can get location details from the Saudi National API. Innovation Award |
composer require naif/saudiaddress
If your Laravel below 5.5 you need to add service provider and alias to config/app.php
Naif\Saudiaddress\SaudiAddressServiceProvider::class,
'SaudiAddress' => Naif\Saudiaddress\Facades\SaudiAddress::class,
Obtain your National Address API key from https://api.address.gov.sa/
Add these to your .env
SAUDI_ADDRESS_API_URL=https://apina.address.gov.sa/NationalAddress/v3.1
SAUDI_ADDRESS_API_KEY=XXXXXXXXXXXXXXXXX
Get a list of regions
$regions = SaudiAddress::regions();
Response:
[
0 => {#181
+"Id": "12"
+"Name": " ??????"
}
1 => {#182
+"Id": "13"
+"Name": " ?????"
}
2 => {#188
+"Id": "9"
+"Name": " ?????? ????????"
}
3 => {#189
+"Id": "1"
+"Name": " ??????"
}
]
Get a list of cities within a region (by region id) * To get a list of all cities don't pass a region id
$cities = SaudiAddress::cities(1);
Response:
[
0 => {#183
+"Id": "3"
+"Name": "??????"
}
1 => {#189
+"Id": "1061"
+"Name": "?????"
}
2 => {#190
+"Id": "828"
+"Name": "???????"
}
3 => {#191
+"Id": "669"
+"Name": "????????"
}
]
Get a list of districts within a city (by city id)
$districts = SaudiAddress::districts(1);
Response:
[
0 => {#184
+"Id": "10700001041"
+"Name": "????? ??? ????? ?????"
}
1 => {#190
+"Id": "10700001018"
+"Name": "?? ??? ????"
}
2 => {#191
+"Id": "10700001021"
+"Name": "?? ????????"
}
3 => {#192
+"Id": "10700001030"
+"Name": "?? ????????"
}
4 => {#193
+"Id": "10700001044"
+"Name": "?? ???????"
}
5 => {#194
+"Id": "10700001012"
+"Name": "?? ??????"
}
]
Geocode, to get address details by geo location (latitude,longitude)
$address = SaudiAddress::geoCode(24.774265,46.738586);
Response:
[
+"Title": null
+"Address1": "7596 ??????? - Al Hamra Dist.,?? ???????"
+"Address2": "RIYADH,?????? 13216 - 2802"
+"ObjLatLng": "1"
+"BuildingNumber": "7596"
+"Street": "???????"
+"District": "Al Hamra Dist.,?? ???????"
+"City": "RIYADH,??????"
+"PostCode": "13216"
+"AdditionalNumber": "2802"
+"RegionName": "????? ??????"
+"PolygonString": null
+"IsPrimaryAddress": null
+"UnitNumber": null
+"Latitude": null
+"Longitude": null
+"CityId": "3"
+"RegionId": null
+"Restriction": "Null"
+"PKAddressID": null
+"DistrictID": null
+"Title_L2": null
+"RegionName_L2": null
+"City_L2": null
+"Street_L2": null
+"District_L2": null
+"CompanyName_L2": null
+"GovernorateID": null
+"Governorate": null
+"Governorate_L2": null
]
Verify an address by (Bulding No, PostCode, Additional No)
$verify = SaudiAddress::verify(7596,13216,2802);
Response:
true/false
To get results in English, just pass 'E' as a last paramater. Example
$districts = SaudiAddress::districts(1,'E');
naif@naif.io
https://www.linkedin.com/in/naif
The MIT License (MIT). Please see License File for more information.
Files |
File | Role | Description | ||
---|---|---|---|---|
src (2 files, 2 directories) | ||||
composer.json | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
config (1 file) | ||||
Facades (1 file) | ||||
SaudiAddress.php | Class | Class source | ||
SaudiAddressServiceProvider.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.