133 行
3.3 KiB
PHP
133 行
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Contracts\Routing\ResponseFactory;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
use App\Http\Controllers\AuthController;
|
|
|
|
class NihonController extends Controller {
|
|
public function __construct() {}
|
|
|
|
public function getGeoRegion () {
|
|
$get = DB::table('nhn_region')->get();
|
|
|
|
foreach ($get as $g) {
|
|
$i = DB::table('nhn_island')->where('id', $g->island_id)->first();
|
|
$g->island = $i;
|
|
|
|
unset($i->id); unset($g->island_id);
|
|
}
|
|
|
|
return $get;
|
|
}
|
|
|
|
public function getGeoPrefecture () {
|
|
$get = DB::table('nhn_prefecture')->get()->toArray();
|
|
|
|
foreach ($get as $g) {
|
|
$r = DB::table('nhn_region')->where('id', $g->region_id)->first();
|
|
$i = DB::table('nhn_island')->where('id', $r->island_id)->first();
|
|
|
|
$g->prefcode = 'JP-'.sprintf("%02d", $g->id);
|
|
$g->region = $r;
|
|
$g->island = $i;
|
|
|
|
unset($r->id); unset($i->id);
|
|
unset($g->region_id); unset($r->island_id);
|
|
}
|
|
|
|
array_unshift($get, array(
|
|
'id' => 0,
|
|
'name' => '',
|
|
'nameKana' => '',
|
|
'nameEng' => '',
|
|
'prefcode' => '',
|
|
'region' => array('name' => '', 'nameKana' => '', 'nameEng' => ''),
|
|
'island' => array('name' => '', 'nameKana' => '', 'nameEng' => '')
|
|
));
|
|
|
|
return $get;
|
|
}
|
|
|
|
public function getGeoIsland () {
|
|
$get = DB::table('nhn_island')->get();
|
|
return $get;
|
|
}
|
|
|
|
public function getGeoCity ($id) {
|
|
$get = DB::table('nhn_city')->where('prefecture_id', $id)->get();
|
|
|
|
foreach ($get as $g) {
|
|
$p = DB::table('nhn_prefecture')->where('id', $g->prefecture_id)->first();
|
|
$r = DB::table('nhn_region')->where('id', $p->region_id)->first();
|
|
$i = DB::table('nhn_island')->where('id', $r->island_id)->first();
|
|
|
|
$dc = DB::table('nhn_city_district')->where('city_id', $g->id)->count();
|
|
|
|
if ($dc > 0) {
|
|
$district = DB::table('nhn_city_district')->where('city_id', $g->id)->get();
|
|
foreach ($district as $d) { unset($d->id); unset($d->city_id); }
|
|
$g->district = $district;
|
|
}
|
|
|
|
$g->prefecture = $p;
|
|
$g->region = $r;
|
|
$g->island = $i;
|
|
|
|
unset($p->id); unset($r->id); unset($i->id);
|
|
unset($g->prefecture_id); unset($p->region_id); unset($r->island_id);
|
|
}
|
|
|
|
return $get;
|
|
}
|
|
|
|
public function getGeoDistrict ($id) {
|
|
$get = DB::table('nhn_city_district')->where('city_id', $id)->get();
|
|
foreach ($get as $g) { unset($g->city_id); }
|
|
return $get;
|
|
}
|
|
|
|
public function getRailCompany () {
|
|
$get = DB::table('nhn_company')->get();
|
|
foreach ($get as $g) { unset($g->id); }
|
|
|
|
return $get;
|
|
}
|
|
|
|
public function getRailLine () {
|
|
$get = DB::table('nhn_line')->get();
|
|
|
|
return $get;
|
|
}
|
|
|
|
public function getRailStation () {
|
|
$get = DB::table('nhn_station')->get();
|
|
|
|
return $get;
|
|
}
|
|
|
|
public function getHistoryPeriod () {
|
|
$get = DB::table('nhn_jidai')->get();
|
|
|
|
foreach ($get as $g) {
|
|
$g->current = ($g->current == 1 ?? false);
|
|
$g->years = ($g->years != 999 ?: '現在');
|
|
$g->finish_date = ($g->finish_date != '2099-12-31' ?: '未定');
|
|
|
|
unset($g->id);
|
|
}
|
|
|
|
return $get;
|
|
}
|
|
|
|
public function getHoliday ($year) {
|
|
$get = DB::table('nhn_holiday')->where('holiday_date', 'LIKE', $year.'-%')->get();
|
|
|
|
return $get;
|
|
}
|
|
}
|