add api negeri poskod daerah

This commit is contained in:
Zakwan Hamdan
2020-11-02 16:56:57 +08:00
parent 07a3185834
commit 6aa1d91f5b
7 changed files with 142 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Daerah extends Model
{
protected $table = 'daerah';
/**
* The attributes that are mass assignable.
*
* @var array
*/
// protected $fillable = [
// ];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
// protected $hidden = [];
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers;
use App\Daerah;
use Illuminate\Http\Request;
class DaerahController extends Controller
{
public function showOneDaerah($koddaerah)
{
$daerah = Daerah::on('mysql7')
->where('koddaerah','=',$koddaerah)
->first();
return response()->json($daerah);
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Http\Controllers;
use App\Negeri;
use Illuminate\Http\Request;
class NegeriController extends Controller
{
public function showOneNegeri($kodnegeri)
{
$negeri = Negeri::on('mysql7')
->where('kodnegeri','=',$kodnegeri)
->first();
return response()->json($negeri);
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Http\Controllers;
use App\Poskod;
use Illuminate\Http\Request;
class PoskodController extends Controller
{
public function showAllPoskod(){
$poskod = Poskod::on('mysql7')->get();
return response()->json($poskod);
}
public function showOnePoskod($poskod)
{
$poskod = Poskod::on('mysql7')
->where('poskod','=',$poskod)
->first();
return response()->json($poskod);
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Negeri extends Model
{
protected $table = 'negeri';
/**
* The attributes that are mass assignable.
*
* @var array
*/
// protected $fillable = [
// ];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
// protected $hidden = [];
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Poskod extends Model
{
protected $table = 'poskod';
/**
* The attributes that are mass assignable.
*
* @var array
*/
// protected $fillable = [
// ];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
// protected $hidden = [];
}
+7
View File
@@ -63,4 +63,11 @@ $router->group(['prefix'=>'api'], function () use ($router){
//Cawangan API
$router->get('cawangan',['uses'=>'CawanganController@showAllCawangans']);
$router->get('cawangan/{code_cawangan}',['uses'=>'CawanganController@showOneCawangan']);
$router->get('poskod',['uses'=>'PoskodController@showAllPoskod']);
$router->get('poskod/{poskod}',['uses'=>'PoskodController@showOnePoskod']);
$router->get('negeri/{kodnegeri}',['uses'=>'NegeriController@showOneNegeri']);
$router->get('daerah/{koddaerah}',['uses'=>'DaerahController@showOneDaerah']);
});