Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
matriphe committed Sep 28, 2015
0 parents commit 52e3410
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
28 changes: 28 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "matriphe/laravel-city-province-id",
"description": "Indonesia city and province data migration and seeder for Laravel.",
"keywords": [
"laravel", "data", "seeder", "city", "province", "indonesia", "id", "ina"
],
"license": "MIT",
"authors": [
{
"name": "Muhammad Zamroni",
"email": "halo@matriphe.com"
}
],
"require": {
"php": ">=5.3.0",
"illuminate/support": ">=4.1 <6.0"
},
"require-dev": {
"illuminate/database": ">=4.1 <6.0",
},
"autoload": {
"psr-4": {
"Matriphe\\LaravelCityProvinceID\\": "src/"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
40 changes: 40 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Laravel 4 - Persistant Settings
*
* @author Andreas Lutro <anlutro@gmail.com>
* @license http://opensource.org/licenses/MIT
* @package l4-settings
*/

namespace Matriphe\LaravelCityProvinceID;

use Illuminate\Foundation\Application;

class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
protected $defer = true;

public function register()
{
if (version_compare(Application::VERSION, '5.0', '>=')) {
$this->mergeConfigFrom(
__DIR__.'/config/config.php', 'laravelcityprovinceid'
);
}
}

public function boot()
{
if (version_compare(Application::VERSION, '5.0', '>=')) {
$this->publishes([
__DIR__.'/config/config.php' => config_path('laravelcityprovinceid.php')
], 'config');

$this->publishes([
__DIR__.'/migrations/' => database_path('migrations')
], 'migrations');
}
}

}
6 changes: 6 additions & 0 deletions src/config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
'city' => 'cities',
'province' => 'provinces',
];
66 changes: 66 additions & 0 deletions src/migrations/2015_09_28_175100_create_city_province_tables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCityProvinceTables extends Migration
{
public function __construct()
{
$this->tablename_city = config('laravelcityprovinceid.city');
$this->tablename_province = config('laravelcityprovinceid.province');
}

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create($this->tablename_city, function(Blueprint $table)
{
$table->smallInteger('city_id', 1, 1);
$table->tinyInteger('province_id')->unsigned()->index();
$table->string('city_name', 50)->index();
$table->string('city_name_full', 100)->index();
$table->enum('city_type', ['kabupaten', 'kota'])->nullable();
$table->float('city_lat', 10, 6)->nullable()->index();
$table->float('city_lon', 10, 6)->nullable()->index();
});
Schema::create($this->tablename_city, function(Blueprint $table)
{
$table->tinyInteger('province_id', 1, 1);
$table->string('province_name', 50);
$table->string('province_name_abbr', 50);
$table->string('province_name_id', 50);
$table->string('province_name_en', 50);
$table->smallInteger('province_capital_city_id')->unsigned()->index();
$table->string('iso_code', 5)->index();
$table->string('iso_name', 50);
$table->enum('iso_type',
[
'province',
'autonomous province',
'special district',
'special region'
]);
$table->string('iso_geounit', 2)->index();
$table->tinyInteger('timezone');
$table->float('province_lat', 10, 6)->nullable()->index();
$table->float('province_lon', 10, 6)->nullable()->index();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop($this->tablename_city);
Schema::drop($this->tablename_province);
}
}

0 comments on commit 52e3410

Please sign in to comment.