Package Data | |
---|---|
Maintainer Username: | matriphe |
Maintainer Contact: | halo@matriphe.com (Muhammad Zamroni) |
Package Create Date: | 2015-09-28 |
Package Last Update: | 2017-12-31 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 03:01:51 |
Package Statistics | |
---|---|
Total Downloads: | 2,475 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 23 |
Total Watchers: | 1 |
Total Forks: | 18 |
Total Open Issues: | 0 |
Indonesia city and province data migration and seeder for Laravel 5.x.
Using composer, run this command from your Laravel's project root directory:
composer require matriphe/laraciproid:~1.0
Nothing to do. Laraciproid will be loaded automatically.
Open config/app.php
and add this line on autoloaded service providers section.
'providers' => [
...
Matriphe\Laraciproid\ServiceProvider::class,
...
],
Open config/app.php
and add this line on autoloaded service providers section.
'providers' => [
...
'Matriphe\Laraciproid\ServiceProvider',
...
],
php artisan vendor:publish
Or if you want to more specific, and want to force the vendor publishing.
php artisan vendor:publish --provider="Matriphe\Laraciproid\ServiceProvider" --force
This command will add these files to your project:
config/laraciproid.php
, the configuration file containing tables name.database/migrations/2015_09_28_175100_create_city_province_tables
, the migration file.database/sql/city.sql
, SQL file for city seed.database/sql/province.sql
, SQL file for province seed.database/json/cities.json
, JSON file for cities seed.database/json/provinces.json
, JSON file for provinces seed.database/seeds/LaraciproidSeeder.php
, table seeder file, read the SQL data.app/Models/City.php
, city model file.app/Models/Province.php
, province model file.php artisan migrate
php artisan db:seed --class=LaraciproidSeeder
You can add this file to your database/seeds/DatabaseSeeder.php
to make it auto loaded on seeding command.
public function run()
{
Model::unguard();
$this->call('LaraciproidSeeder');
}
Province table has one to many relationship of City table.
// Get all cities under DI Yogyakarta (province_id = 34)
$cities = App\Models\Province::find(34)->cities;
foreach ($cities as $city) {
// Do something
}
// Get province name of Bogor (city_id = 3271)
$city = App\Models\City::find(3271);
$province_name = $city->province->province_name;
The MIT License (MIT). Please see License File for more information.