w3-devmaster / laravel-geodata
Geo data package for laravel framework
1.0.0
2023-11-09 09:01 UTC
Requires
- php: >=7.4
README
Installation
Install with composer :
composer require w3-devmaster/laravel-geodata
Publish package files :
php artisan geodata:publish
Install package datas :
php artisan geodata:install
Basic Use
Get geography datas :
use W3Devmaster\GeoData\GeoData; $geodata = new GeoData(); $geographies = $geodata->geographies(); $provinces = $geodata->provinces(); $districts = $geodata->districts(); $subDistricts = $geodata->subDistricts(); // Or use static method $geographies = GeoData::geographies(); $provinces = GeoData::provinces(); $districts = GeoData::districts(); $subDistricts = GeoData::subDistricts();
Get relate data :
use W3Devmaster\GeoData\GeoData; $province = GeoData::provinces()->first(); $districts = $province->districts;
Get parent data :
use W3Devmaster\GeoData\GeoData; $province = GeoData::provinces()->first(); $geography = $province->geography;
Use query scope and|or eloqent :
use W3Devmaster\GeoData\GeoData; $provinces = GeoData::provinces()->findName('นครร')->get(); // Like Condition
Helpers
Get data for all sector :
$geographies = geographies(); $provinces = provinces(); $districts = districts(); $subDistricts = subDistricts(); $provinces = provinces()->findName('นครร')->get(); // Like Condition
Get single data for all sector :
$geo_name = geography($id)->name_th; $province_name = province($id)->name_th; $district_name = district($id)->name_th; $sub_dis_name = subDistrict($id)->zip_code;
Optional
Add Geo
facades to the aliases
array in your config/app.php
for use Geo::class
:
'aliases' => Facade::defaultAliases()->merge([ // 'Example' => App\Facades\Example::class, ..., 'Geo' => W3Devmaster\GeoData\Facades\Geo::class, ])->toArray(),
For can use
use Geo; $geodata = new Geo(); // Or $geographies = Geo::geographies();
Changelog
Please see CHANGELOG for more information what has changed recently.