api for customer online update
This commit is contained in:
@@ -46,7 +46,12 @@ class DailyGadai extends Command
|
||||
foreach($cawangan as $cawangan_mysql){
|
||||
$all_gadai = Gadai::on($cawangan_mysql['mysql'])->where('sttebus','!=','L')->orWhere('sttebus','!=','T')->get();
|
||||
foreach($all_gadai as $gadai){
|
||||
$tarikh_gadai = Carbon::parse($gadai['t_gadai'].' '. $gadai['masa']);
|
||||
if($gadai['t_update'] == null){
|
||||
$tarikh_gadai = Carbon::parse($gadai['t_gadai'].' '. $gadai['masa']);
|
||||
}else{
|
||||
$tarikh_gadai = Carbon::parse($gadai['t_update'].' 00:00:00' );
|
||||
}
|
||||
|
||||
$diff = date_diff($tarikh_gadai,$current);
|
||||
$month = $diff->format("%m");
|
||||
$days = $diff->format("%d");
|
||||
|
||||
@@ -30,6 +30,6 @@ class Kernel extends ConsoleKernel
|
||||
{
|
||||
//
|
||||
|
||||
$schedule->command('gadai:daily')->daily()->timezone('Asia/Kuala_Lumpur');
|
||||
$schedule->command('gadai:daily')->daily()->timezone('Asia/Kuala_Lumpur')->at('00:00');
|
||||
}
|
||||
}
|
||||
|
||||
+46
-4
@@ -7,15 +7,57 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Customer extends Model
|
||||
{
|
||||
protected $table = 'customer';
|
||||
|
||||
public $timestamps = false;
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
// protected $fillable = [
|
||||
|
||||
// ];
|
||||
protected $fillable = [
|
||||
'ahli',
|
||||
'kodcaw',
|
||||
'nosiri',
|
||||
'tarikhdaftar',
|
||||
'nopelanggan',
|
||||
'kplama',
|
||||
'kpbaru',
|
||||
'nama',
|
||||
't_lahir',
|
||||
'jantina',
|
||||
'alamat1',
|
||||
'alamat2',
|
||||
'alamat3',
|
||||
'alamat4',
|
||||
'poskod',
|
||||
'koddaerah',
|
||||
'kodnegeri',
|
||||
'telefon',
|
||||
'jumpinjaman',
|
||||
't_gadai',
|
||||
'pinjamhari',
|
||||
'bumiputra',
|
||||
'warganegara',
|
||||
'bangsa',
|
||||
'kodkerja',
|
||||
'kodugama',
|
||||
'kodstatus',
|
||||
'kodbank',
|
||||
'noakaun',
|
||||
'nota' ,
|
||||
'teller',
|
||||
'pelulus',
|
||||
't_ubah',
|
||||
'm_ubah',
|
||||
'aktif',
|
||||
'yuranahli',
|
||||
'tujuangadai',
|
||||
'kodkerjabaru',
|
||||
'nopelangganlama',
|
||||
'tagperingatan',
|
||||
'kumpulan',
|
||||
'telefon2',
|
||||
'tagpelanggan'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Customer;
|
||||
use App\Gadai;
|
||||
use App\Lelong;
|
||||
use App\Cawangan;
|
||||
use App\Poskod;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CustomerController extends Controller
|
||||
@@ -114,6 +115,32 @@ class CustomerController extends Controller
|
||||
return response()->json($customer, 200);
|
||||
}
|
||||
|
||||
public function updateOnline($nokp,Request $request){
|
||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
||||
foreach($cawangan_all as $index=>$cawangan){
|
||||
$customer = Customer::on($cawangan['mysql'])
|
||||
->where('kplama','=',$nokp)
|
||||
->orWhere('kpbaru','=',$nokp)
|
||||
->first();
|
||||
if($customer != null){
|
||||
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
|
||||
$customer_update = Customer::on($cawangan['mysql'])
|
||||
->where('kplama','=',$nokp)
|
||||
->orWhere('kpbaru','=',$nokp)
|
||||
->update(array(
|
||||
'alamat1' => $request->alamat,
|
||||
'poskod' => $request->poskod,
|
||||
'koddaerah' => $poskod['koddaerah'],
|
||||
'kodnegeri' => $poskod['kodnegeri'],
|
||||
'telefon' => $request->telefon1,
|
||||
'telefon2' => $request->telefon2
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($customer_update, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Customer::findOrFail($id)->delete();
|
||||
|
||||
@@ -31,9 +31,14 @@ class MarhunController extends Controller
|
||||
return response()->json($marhun_all);
|
||||
}
|
||||
|
||||
public function getAllJemas($kodcaw){
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$jemas = Jemas::on($cawangan['mysql'])->get();
|
||||
public function getMarhunName (Request $request){
|
||||
$jemas = Jemas::on('mysql7')->where('marhun','=',$request->marhun)->first();
|
||||
|
||||
return response()->json($jemas);
|
||||
}
|
||||
|
||||
public function getAllJemas(){
|
||||
$jemas = Jemas::on('mysql7')->get();
|
||||
|
||||
return response()->json($jemas);
|
||||
}
|
||||
|
||||
+5
-2
@@ -27,7 +27,8 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->get('customers/{ic}/gadai/{status}/{kodcaw}',['uses'=>'CustomerController@showOneCustomerGadaiByCawangan']);
|
||||
$router->post('customers',['uses'=>'CustomerController@create']);
|
||||
$router->delete('customers/{id}', ['uses' => 'CustomerController@delete']);
|
||||
$router->put('customers/{id}', ['uses' => 'CustomerController@update']);
|
||||
// $router->put('customers/{id}', ['uses' => 'CustomerController@update']);
|
||||
$router->put('customersonline/{nokp}', ['uses' => 'CustomerController@updateOnline']);
|
||||
|
||||
//Gadai API
|
||||
$router->get('gadai',['uses'=>'GadaiController@showAllGadais']);
|
||||
@@ -55,7 +56,9 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
||||
$router->post('marhun/{kodcaw}',['uses'=>'MarhunController@create']);
|
||||
$router->put('marhun/{id}', ['uses' => 'MarhunController@update']);
|
||||
|
||||
$router->get('jemas/{kodcaw}',['uses'=>'MarhunController@getAllJemas']);
|
||||
|
||||
$router->get('jemas',['uses'=>'MarhunController@getAllJemas']);
|
||||
$router->get('jemas/nama_marhun',['uses'=>'MarhunController@getMarhunName']);
|
||||
|
||||
|
||||
//Harga Emas API
|
||||
|
||||
Reference in New Issue
Block a user