add customer
This commit is contained in:
@@ -9,17 +9,22 @@ use App\Cawangan;
|
|||||||
use App\Poskod;
|
use App\Poskod;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class CustomerController extends Controller
|
class CustomerController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
public function showAllCustomers()
|
public function showAllCustomers()
|
||||||
{
|
{
|
||||||
return response()->json(Customer::on('mysql2')->get());
|
$cawangan_all = Cawangan::on('mysql7')->get();
|
||||||
}
|
$customer_all = [];
|
||||||
|
foreach($cawangan_all as $index=>$cawangan){
|
||||||
public function showOneCustomer($id)
|
$customer = Customer::on($cawangan['mysql'])->get();
|
||||||
{
|
if($customer != null){
|
||||||
return response()->json(Customer::on('mysql2')->find($id));
|
array_push($customer_all,$customer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response()->json($customer_all);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showOneCustomerByIC($ic){
|
public function showOneCustomerByIC($ic){
|
||||||
@@ -97,25 +102,40 @@ class CustomerController extends Controller
|
|||||||
return response()->json($gadai);
|
return response()->json($gadai);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create(Request $request)
|
public function create($kodcaw,Request $request){
|
||||||
{
|
$current = Carbon::now();
|
||||||
$this->validate($request, [
|
$current = new Carbon();
|
||||||
|
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
|
$customer = Customer::on($cawangan['mysql'])->create([
|
||||||
|
'kodcaw' => $request->kodcaw,
|
||||||
|
'tarikhdaftar' => $current->toDateString(),
|
||||||
|
'nopelanggan' => $request->nopelanggan,
|
||||||
|
'kpbaru' => $request->nokp,
|
||||||
|
'nama' => $request->nama,
|
||||||
|
't_lahir' => $request->t_lahir,
|
||||||
|
'jantina' => $request->jantina,
|
||||||
|
'alamat1' => $request->alamat,
|
||||||
|
'poskod' => $request->poskod,
|
||||||
|
'koddaerah' => $request->koddaerah,
|
||||||
|
'kodnegeri' => $request->kodnegeri,
|
||||||
|
'telefon' => $request->telefon,
|
||||||
|
'bumiputra' => $request->bumiputra,
|
||||||
|
'warganegara' => $request->warganegara,
|
||||||
|
'bangsa' => $request->bangsa,
|
||||||
|
'kodugama' => $request->kodugama,
|
||||||
|
'kodbank' => $request->kodbank,
|
||||||
|
'noakaun' => $request->noakaun,
|
||||||
|
'teller' => $request->teller,
|
||||||
|
'aktif' => 'A',
|
||||||
|
'telefon2' => $request->telefon2
|
||||||
]);
|
]);
|
||||||
$customer = Customer::create($request->all());
|
|
||||||
|
|
||||||
return response()->json($customer, 201);
|
return response()->json($customer, 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id, Request $request)
|
public function customerUpdate($nokp,Request $request){
|
||||||
{
|
|
||||||
$customer = Customer::findOrFail($id);
|
|
||||||
$customer->update($request->all());
|
|
||||||
|
|
||||||
return response()->json($customer, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateOnline($nokp,Request $request){
|
|
||||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
$cawangan_all = Cawangan::on('mysql7')->get();
|
||||||
foreach($cawangan_all as $index=>$cawangan){
|
foreach($cawangan_all as $index=>$cawangan){
|
||||||
$customer = Customer::on($cawangan['mysql'])
|
$customer = Customer::on($cawangan['mysql'])
|
||||||
@@ -142,9 +162,12 @@ class CustomerController extends Controller
|
|||||||
return response()->json($customer_update, 200);
|
return response()->json($customer_update, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id)
|
public function delete($kodcaw,$nokp)
|
||||||
{
|
{
|
||||||
Customer::findOrFail($id)->delete();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
|
Customer::on($cawangan['mysql'])->where('kplama','=',$nokp)->orWhere('kpbaru','=',$nokp)->delete();
|
||||||
|
|
||||||
return response('Deleted Successfully', 200);
|
return response('Deleted Successfully', 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,14 +125,6 @@ class GadaiController extends Controller
|
|||||||
return response()->json($gadai, 200);
|
return response()->json($gadai, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($id, Request $request)
|
|
||||||
{
|
|
||||||
$gadai = Gadai::findOrFail($id);
|
|
||||||
$gadai->update($request->all());
|
|
||||||
|
|
||||||
return response()->json($gadai, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTransactionByTarikh($kodcaw,$tarikh){
|
public function getTransactionByTarikh($kodcaw,$tarikh){
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
@@ -236,12 +228,6 @@ class GadaiController extends Controller
|
|||||||
return response()->json($gadai);
|
return response()->json($gadai);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($id)
|
|
||||||
{
|
|
||||||
Gadai::findOrFail($id)->delete();
|
|
||||||
return response('Deleted Successfully', 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function batalGadai($kodcaw, $norujukan){
|
public function batalGadai($kodcaw, $norujukan){
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||||
|
|
||||||
|
|||||||
+3
-7
@@ -21,14 +21,12 @@ $router->get('/', function () use ($router) {
|
|||||||
$router->group(['prefix'=>'api'], function () use ($router){
|
$router->group(['prefix'=>'api'], function () use ($router){
|
||||||
//Customer API
|
//Customer API
|
||||||
$router->get('customers',['uses'=>'CustomerController@showAllCustomers']);
|
$router->get('customers',['uses'=>'CustomerController@showAllCustomers']);
|
||||||
// $router->get('customers/{id}',['uses'=>'CustomerController@showOneCustomer']);
|
|
||||||
$router->get('customers/{ic}',['uses'=>'CustomerController@showOneCustomerByIC']);
|
$router->get('customers/{ic}',['uses'=>'CustomerController@showOneCustomerByIC']);
|
||||||
$router->get('customers/{ic}/gadai/{status}',['uses'=>'CustomerController@showOneCustomerGadai']);
|
$router->get('customers/{ic}/gadai/{status}',['uses'=>'CustomerController@showOneCustomerGadai']);
|
||||||
$router->get('customers/{ic}/gadai/{status}/{kodcaw}',['uses'=>'CustomerController@showOneCustomerGadaiByCawangan']);
|
$router->get('customers/{ic}/gadai/{status}/{kodcaw}',['uses'=>'CustomerController@showOneCustomerGadaiByCawangan']);
|
||||||
$router->post('customers',['uses'=>'CustomerController@create']);
|
$router->post('customers/{kodcaw}',['uses'=>'CustomerController@create']);
|
||||||
$router->delete('customers/{id}', ['uses' => 'CustomerController@delete']);
|
$router->delete('customers/{kodcaw}/{nokp}', ['uses' => 'CustomerController@delete']);
|
||||||
// $router->put('customers/{id}', ['uses' => 'CustomerController@update']);
|
$router->put('customers/update/{nokp}', ['uses' => 'CustomerController@customerUpdate']);
|
||||||
$router->put('customersonline/{nokp}', ['uses' => 'CustomerController@updateOnline']);
|
|
||||||
|
|
||||||
//Gadai API
|
//Gadai API
|
||||||
$router->get('gadai',['uses'=>'GadaiController@showAllGadais']);
|
$router->get('gadai',['uses'=>'GadaiController@showAllGadais']);
|
||||||
@@ -36,8 +34,6 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
$router->get('gadai/norujukan/{norujukan}',['uses'=>'GadaiController@showOneGadaiByNorujukan']);
|
$router->get('gadai/norujukan/{norujukan}',['uses'=>'GadaiController@showOneGadaiByNorujukan']);
|
||||||
$router->get('gadai/norujukan/{kodcaw}/{norujukan}',['uses'=>'GadaiController@showOneGadaibyRujukanAndCawangan']);
|
$router->get('gadai/norujukan/{kodcaw}/{norujukan}',['uses'=>'GadaiController@showOneGadaibyRujukanAndCawangan']);
|
||||||
$router->post('gadai/{kodcaw}',['uses'=>'GadaiController@create']);
|
$router->post('gadai/{kodcaw}',['uses'=>'GadaiController@create']);
|
||||||
$router->delete('gadai/{id}', ['uses' => 'GadaiController@delete']);
|
|
||||||
$router->put('gadai/{id}', ['uses' => 'GadaiController@update']);
|
|
||||||
$router->get('gadai/{cawangan_code}/{date}',['uses'=>'GadaiController@gadaiTransactionByCawanganAndDay']);
|
$router->get('gadai/{cawangan_code}/{date}',['uses'=>'GadaiController@gadaiTransactionByCawanganAndDay']);
|
||||||
$router->put('gadai/norujukan/{norujukan}',['uses'=>'GadaiController@updateOneGadaiByNorujukan']);
|
$router->put('gadai/norujukan/{norujukan}',['uses'=>'GadaiController@updateOneGadaiByNorujukan']);
|
||||||
$router->put('gadai/{kodcaw}/norujukan/{norujukan}',['uses'=>'GadaiController@updateGadaiMarhunOnline']);
|
$router->put('gadai/{kodcaw}/norujukan/{norujukan}',['uses'=>'GadaiController@updateGadaiMarhunOnline']);
|
||||||
|
|||||||
Reference in New Issue
Block a user