Merged in izzati-ujrah (pull request #49)
tambah function notis peringatan dalam arcc dan blast wasap dan sms
This commit is contained in:
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class CawanganNotis extends Model
|
||||
{
|
||||
protected $table = 'cawangan_notis';
|
||||
public $timestamps = false;
|
||||
public $timestamps = true;
|
||||
protected $primaryKey = 'id';
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
@@ -36,8 +36,8 @@ use App\Jobs\SMSPelangganSAGLAMA;
|
||||
use Illuminate\Http\Request;
|
||||
use App\CawanganDetail;
|
||||
use App\BlastSMS;
|
||||
use App\Jobs\WhatsappPelangganSAGLAMAbysag;
|
||||
use App\Jobs\SMSPelangganSAGLAMAbysag;
|
||||
use App\Jobs\ARCCWhatsappPelangganSAGLAMAbysag;
|
||||
use App\Jobs\ARCCSMSPelangganSAGLAMAbysag;
|
||||
|
||||
use App\Services\OnePercentServices;
|
||||
|
||||
@@ -47,9 +47,22 @@ use Carbon\Carbon;
|
||||
|
||||
class CallCenterController extends Controller
|
||||
{
|
||||
public function showAllCawangans()
|
||||
public function showAllCawangans(Request $request)
|
||||
{
|
||||
return response()->json(Cawangan::on('mysql7')->orderBy('details_caw','ASC')->get());
|
||||
$daritempoh = $request->daritempoh;
|
||||
$hinggatempoh = $request->hinggatempoh;
|
||||
$checkcawangannotis = Cawangan::on('mysql7')
|
||||
// ->whereNotExists(function($query) use($daritempoh,$hinggatempoh)
|
||||
// {
|
||||
// $query->select(DB::raw(1))
|
||||
// ->from('cawangan_notis')
|
||||
// ->whereRaw('cawangan_notis.kodcaw = arrahn_master_db.kodcaw')
|
||||
// ->where('daritempoh','=',$daritempoh)
|
||||
// ->where('hinggatempoh','=',$hinggatempoh);
|
||||
// } )
|
||||
->orderBy('details_caw','ASC')->get();
|
||||
// dd($checkcawangannotis);
|
||||
return response()->json($checkcawangannotis);
|
||||
}
|
||||
public function datagadai($kodcaw,Request $request)
|
||||
{
|
||||
@@ -58,7 +71,7 @@ class CallCenterController extends Controller
|
||||
$hinggatempoh = $request->hinggatempoh;
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$datagadai = Gadai::on($cawangan['mysql'])
|
||||
->where([['tagpalsu','=',0],['tempoh','>=',$daritempoh],['tempoh','<=',$hinggatempoh],['sttebus','=',''],['taglel','=',0]])
|
||||
->where([['tagpalsu','=',0],['tempoh','>=',$daritempoh],['tempoh','<=',$hinggatempoh],['sttebus','=',''],['taglel','=',0],['tagnotis','=',0]])
|
||||
->orderBy('t_gadai', 'ASC')
|
||||
->orderBy('sirig', 'ASC');
|
||||
// ->get();
|
||||
@@ -100,7 +113,7 @@ class CallCenterController extends Controller
|
||||
// ]);
|
||||
|
||||
$datagadai = Gadai::on($cawangan['mysql'])
|
||||
->where([['tagpalsu','=',0],['tempoh','>=',$daritempoh],['tempoh','<=',$hinggatempoh],['sttebus','=',''],['taglel','=',0]])
|
||||
->where([['tagpalsu','=',0],['tempoh','>=',$daritempoh],['tempoh','<=',$hinggatempoh],['sttebus','=',''],['taglel','=',0],['tagnotis','=',0]])
|
||||
->orderBy('t_gadai', 'ASC')
|
||||
->orderBy('sirig', 'ASC');
|
||||
// ->get();
|
||||
@@ -143,6 +156,11 @@ class CallCenterController extends Controller
|
||||
$notis_to_be_inserted->percent = $surat->percentpinj;
|
||||
$notis_to_be_inserted->peringatan = '1';
|
||||
$notis_peringatan_arr[] = $notis_to_be_inserted->attributesToArray();
|
||||
|
||||
//updatetagnotisdlmgadai
|
||||
$updateTagNotis = Gadai::on($cawangan['mysql'])->where('norujukan',$surat->norujukan)->update([
|
||||
'tagnotis'=> 1
|
||||
]);
|
||||
}
|
||||
|
||||
$notis_peringatan_collection = collect($notis_peringatan_arr);
|
||||
@@ -214,31 +232,140 @@ class CallCenterController extends Controller
|
||||
|
||||
public function getcawnotisbycaw(Request $request)
|
||||
{
|
||||
$notisid = $request->notisid;
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$arraybatch = [];
|
||||
$batchnotis = Notis::on('mysql7')->where('id',$notisid)->get();
|
||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
||||
$cawnotis_all = [];
|
||||
|
||||
$notis = CawanganNotis::on('mysql7')
|
||||
->join('arrahn_master_db', 'arrahn_master_db.kodcaw', '=', 'cawangan_notis.kodcaw')
|
||||
->where('notis_id',$notisid)->get();
|
||||
|
||||
foreach ($notis as $index => $cawangan){
|
||||
// dd($cawangan['kodcaw']);
|
||||
// dd($cawangan);
|
||||
$notisbycaw = NotisPeringatan::on('mysql7')
|
||||
->where('notisperingatan.notis_id',$notisid)->where('notisperingatan.kodcaw',$cawangan['kodcaw'])
|
||||
->distinct()
|
||||
->get();
|
||||
// dd($notisbycaw);
|
||||
|
||||
$totalsag = $notisbycaw->count('norujukan');
|
||||
$totalbakipjm = $notisbycaw->sum('pinjaman');
|
||||
|
||||
// if(sizeof($notis) != 0){
|
||||
array_push($cawnotis_all,['namacaw' => $notis, 'detailbycaw' => $notisbycaw,'totalsag' =>$totalsag,'totalbakipjm' =>$totalbakipjm]);
|
||||
// }
|
||||
}
|
||||
return response()->json($cawnotis_all);
|
||||
}
|
||||
|
||||
public function bycawnotisperingatan($kodcaw,$notisid)
|
||||
{
|
||||
$cawnotis_all = [];
|
||||
|
||||
$notisbycaw = NotisPeringatan::on('mysql7')
|
||||
->where('notisperingatan.notis_id',$notisid)->where('notisperingatan.kodcaw',$kodcaw)
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
$notisbycawarray = $notisbycaw->toArray();
|
||||
|
||||
foreach($notisbycawarray as $index=>$cal){
|
||||
$customer = Customer::where('kpbaru','=',$cal['nokp'])
|
||||
->orWhere('kplama','=',$cal['nokp'])
|
||||
->first();
|
||||
|
||||
$notisbycawarray[$index]['namacust'] = $customer;
|
||||
}
|
||||
|
||||
array_push($notisbycawarray);
|
||||
return response()->json($notisbycawarray);
|
||||
}
|
||||
|
||||
public function blastwasapbysag(Request $request)
|
||||
{
|
||||
// dd($request->all());
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$kodcaw = $request->kodcaw;
|
||||
$notisid = $request->notisid;
|
||||
|
||||
$arraybatch = [];
|
||||
$batchnotis = CawanganNotis::on('mysql7')->where('id',$notisid)->where('kodcaw',$kodcaw)->get();
|
||||
$cawnotis_all = [];
|
||||
foreach ($batchnotis as $index => $cawangan){
|
||||
$notis = NotisPeringatan::on('mysql7')
|
||||
->join('arrahn_master_db', 'arrahn_master_db.kodcaw', '=', 'notisperingatan.kodcaw')
|
||||
->join('cawangan_notis', 'cawangan_notis.kodcaw', '=', 'notisperingatan.kodcaw')
|
||||
->where('cawangan_notis.notis_id',$notisid)->where('cawangan_notis.kodcaw',$kodcaw)->get();
|
||||
$namapengguna = $request->namapengguna;
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$request->kodcaw)->first();
|
||||
$cawangan_detail = CawanganDetail::on($cawangan['mysql'])->first();
|
||||
$caw_name = $cawangan->details_caw;
|
||||
$nofoncaw = $cawangan_detail->notel;
|
||||
|
||||
$totalsag = $notis->count('norujukan');
|
||||
// dd($totalsag);
|
||||
if(sizeof($notis) != 0){
|
||||
array_push($cawnotis_all,$notis);
|
||||
$statusblast = CawanganNotis::where('notis_id','=',$notisid)
|
||||
->where('kodcaw','=',$kodcaw)
|
||||
->first();
|
||||
if($statusblast->status == '1'){
|
||||
|
||||
$notisbycaw = NotisPeringatan::on('mysql7')
|
||||
->where('notisperingatan.notis_id',$notisid)->where('notisperingatan.kodcaw',$kodcaw)
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
$arraynorujukan = $notisbycaw->pluck('norujukan')->toArray();
|
||||
|
||||
$gadainokp = Gadai::on($cawangan['mysql'])->whereIn('norujukan', $arraynorujukan)
|
||||
->get();
|
||||
$gadai_all_groupby_nokp = $notisbycaw->groupBy('nokp');
|
||||
|
||||
foreach($gadainokp as $index1=>$cal){
|
||||
if($gadai_all_groupby_nokp[$cal->nokp]){
|
||||
$gadainokp[$index1]['gadai'] = $gadai_all_groupby_nokp[$cal->nokp];
|
||||
}
|
||||
$customer = Customer::on('mysql7')->where('kpbaru','=',$cal['nokp'])
|
||||
->orWhere('kplama','=',$cal['nokp'])
|
||||
->first();
|
||||
$nokp=$cal['nokp'];
|
||||
// dd($customer);
|
||||
if($customer->telefon != 'null'){
|
||||
$telefon=$customer->telefon;
|
||||
//log auditrail
|
||||
$audit = new Audit();
|
||||
$audit->users = $namapengguna;
|
||||
$audit->actions = 'ARCC Blast Whatsapp & SMS: Notis ID'.$notisid;
|
||||
$audit->norujukan = $cal->norujukan;
|
||||
$audit->new_data = $customer->telefon;
|
||||
$audit->old_data = $nokp;
|
||||
$audit->kodcaw = $kodcaw;
|
||||
$audit->created_at = $current;
|
||||
$audit->updated_at = $current;
|
||||
$audit->save();
|
||||
|
||||
$today = $current->toDateString();
|
||||
$harini = date('Y-m-d',strtotime($today));
|
||||
|
||||
//update tarikh dlm table notisperingatan
|
||||
$updatenotis=NotisPeringatan::on('mysql7')
|
||||
->where('norujukan','=', $cal->norujukan)
|
||||
->update(
|
||||
array('tarikhnotis1'=> $harini));
|
||||
|
||||
dispatch(new ARCCWhatsappPelangganSAGLAMAbysag($nokp,$customer->telefon,$caw_name,$nofoncaw,$kodcaw,$cal->norujukan,$cal->tempoh,$cal->t_matang,$cal->t_matang1,$cal->lelong_tawarruq,$namapengguna));
|
||||
dispatch(new ARCCSMSPelangganSAGLAMAbysag($nokp,$customer->telefon,$caw_name,$nofoncaw,$kodcaw,$cal->norujukan,$cal->tempoh,$cal->t_matang,$cal->t_matang1,$cal->lelong_tawarruq,$namapengguna));
|
||||
}
|
||||
}
|
||||
|
||||
$updatestatusnotis=CawanganNotis::on('mysql7')
|
||||
->where('notis_id','=', $notisid)
|
||||
->where('kodcaw','=', $kodcaw)
|
||||
->update(
|
||||
array('status'=> 2));
|
||||
|
||||
return response()->json('success');
|
||||
}
|
||||
else{
|
||||
return response()->json('failed');
|
||||
}
|
||||
}
|
||||
// dd($cawnotis_all);
|
||||
|
||||
$arrayrekod = ['rekod' => $cawnotis_all,'totalsag' =>$totalsag];
|
||||
return response()->json($arrayrekod);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\BlastSMS;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ARCCSMSPelangganSAGLAMAbysag extends Job
|
||||
{
|
||||
public $nokp;
|
||||
public $telefon;
|
||||
public $caw_name;
|
||||
public $nofoncaw;
|
||||
public $kodcaw;
|
||||
public $norujukan;
|
||||
public $tempoh;
|
||||
public $tmatang;
|
||||
public $tmatang1;
|
||||
public $lelong_tawarruq;
|
||||
public $namapengguna;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($nokp, $telefon, $caw_name,$nofoncaw,$kodcaw,$norujukan,$tempoh,$tmatang,$tmatang1,$lelong_tawarruq,$namapengguna)
|
||||
{
|
||||
$this->nokp = $nokp;
|
||||
$this->telefon = $telefon;
|
||||
$this->caw_name = $caw_name;
|
||||
$this->nofoncaw = $nofoncaw;
|
||||
$this->kodcaw = $kodcaw;
|
||||
$this->norujukan = $norujukan;
|
||||
$this->tempoh = $tempoh;
|
||||
$this->tmatang = $tmatang;
|
||||
$this->tmatang1 = $tmatang1;
|
||||
$this->lelong_tawarruq = $lelong_tawarruq;
|
||||
$this->namapengguna = $namapengguna;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$mobile_no = ltrim($this->telefon, '+6');
|
||||
// $mobile_no = '60178916936';
|
||||
// $message = 'test';
|
||||
$tarikhmatang = $this->tmatang;
|
||||
$tarikhmatangnew = date('d-m-Y',strtotime($tarikhmatang));
|
||||
$tarikhmatang1 = $this->tmatang1;
|
||||
$tarikhmatang1new = date('d-m-Y',strtotime($tarikhmatang1));
|
||||
$today = $current->toDateString();
|
||||
// $current_date = new Carbon($current->toDateString());
|
||||
if($this->lelong_tawarruq == '1'){
|
||||
if($tarikhmatang > $today){
|
||||
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum '.$tarikhmatangnew.'.';
|
||||
}elseif($tarikhmatang < $today){
|
||||
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah tamat tempoh pada '.$tarikhmatangnew.', Sila perbaharui SAG anda di cawangan Ar-Rahn.';}
|
||||
}else
|
||||
if($tarikhmatang1 > $today){
|
||||
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum '.$tarikhmatang1new.'.';
|
||||
}elseif($tarikhmatang1 <= $today){
|
||||
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, '.$this->norujukan.' telah tamat tempoh pada '.$tarikhmatang1new.', Sila perbaharui SAG anda di cawangan Ar-Rahn.';}
|
||||
|
||||
if(env('APP_ENV') != 'production'){
|
||||
$mobile_no = env('ADMIN_PHONE_NUMBER');
|
||||
}
|
||||
$response = Http::get(env('ONEWAYSMS_API'), [
|
||||
'apiusername' => env('ONEWAYSMS_AUTH_USER'),
|
||||
'apipassword' => env('ONEWAYSMS_AUTH_PASS'),
|
||||
'senderid' => 'INFO',
|
||||
'mobileno' => $mobile_no,
|
||||
'message' => $message,
|
||||
'languagetype' => 1
|
||||
]);
|
||||
|
||||
//insert log blast sms
|
||||
$logblastsms = new BlastSMS();
|
||||
$logblastsms->kodcaw = $this->kodcaw;
|
||||
$logblastsms->nokp = $this->nokp;
|
||||
$logblastsms->notelefon = $this->telefon;
|
||||
$logblastsms->norujukan = $this->norujukan;
|
||||
$logblastsms->tempoh = $this->tempoh;
|
||||
$logblastsms->status = $response;
|
||||
$logblastsms->created_at = $current;
|
||||
$logblastsms->updated_at = $current;
|
||||
$logblastsms->nama = $this->namapengguna;
|
||||
$logblastsms->save();
|
||||
|
||||
Log::info("ARCC SMS - Pelanggan ".$this->caw_name." SAG Tawarruq -".$mobile_no);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\BlastWasap;
|
||||
use App\NotisPeringatan;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ARCCWhatsappPelangganSAGLAMAbysag extends Job
|
||||
{
|
||||
public $nokp;
|
||||
public $telefon;
|
||||
public $caw_name;
|
||||
public $nofoncaw;
|
||||
public $kodcaw;
|
||||
public $norujukan;
|
||||
public $tempoh;
|
||||
public $tmatang;
|
||||
public $tmatang1;
|
||||
public $lelong_tawarruq;
|
||||
public $namapengguna;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($nokp, $telefon, $caw_name,$nofoncaw,$kodcaw,$norujukan,$tempoh,$tmatang,$tmatang1,$lelong_tawarruq, $namapengguna)
|
||||
{
|
||||
$this->nokp = $nokp;
|
||||
$this->telefon = $telefon;
|
||||
$this->caw_name = $caw_name;
|
||||
$this->nofoncaw = $nofoncaw;
|
||||
$this->kodcaw = $kodcaw;
|
||||
$this->norujukan = $norujukan;
|
||||
$this->tempoh = $tempoh;
|
||||
$this->tmatang = $tmatang;
|
||||
$this->tmatang1 = $tmatang1;
|
||||
$this->lelong_tawarruq = $lelong_tawarruq;
|
||||
$this->namapengguna = $namapengguna;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$mobile_no = ltrim($this->telefon, '+6');
|
||||
// $mobile_no = '60178916936';
|
||||
$tarikhmatang = $this->tmatang;
|
||||
$tarikhmatangnew = date('d-m-Y',strtotime($tarikhmatang));
|
||||
$tarikhmatang1 = $this->tmatang1;
|
||||
$tarikhmatang1new = date('d-m-Y',strtotime($tarikhmatang1));
|
||||
$today = $current->toDateString();
|
||||
if($this->lelong_tawarruq == '1'){
|
||||
if($tarikhmatang > $today){
|
||||
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum *'.$tarikhmatangnew.'*.';
|
||||
}elseif($tarikhmatang <= $today){
|
||||
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah tamat tempoh pada *'.$tarikhmatangnew.'*, Sila perbaharui SAG anda di cawangan AR-RAHN.';}
|
||||
}else
|
||||
if($tarikhmatang1 > $today){
|
||||
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah hampir tamat tempoh untuk tukar ke SAG baru, Sila perbaharui SAG anda di cawangan sebelum *'.$tarikhmatang1new.'*.';
|
||||
}elseif($tarikhmatang1 <= $today){
|
||||
$message = 'AR-RAHN '.$this->caw_name.': MAKLUMAN, *'.$this->norujukan.'* telah tamat tempoh pada *'.$tarikhmatang1new.'*, Sila perbaharui SAG anda di cawangan Ar-Rahn.';}
|
||||
|
||||
if(env('APP_ENV') != 'production'){
|
||||
$mobile_no = env('ADMIN_PHONE_NUMBER');
|
||||
}
|
||||
$response = Http::get(env('WABOT_API'), [
|
||||
'number' => $mobile_no,
|
||||
'type' => 'text',
|
||||
'message' => $message,
|
||||
'instance_id' => env('WABOT_INSTANCES_ID'),
|
||||
'access_token' => env('WABOT_TOKEN_KEYS')
|
||||
]);
|
||||
|
||||
|
||||
|
||||
//insert log blast wasap
|
||||
$logblastwasap = new BlastWasap();
|
||||
$logblastwasap->kodcaw = $this->kodcaw;
|
||||
$logblastwasap->nokp = $this->nokp;
|
||||
$logblastwasap->notelefon = $this->telefon;
|
||||
$logblastwasap->norujukan = $this->norujukan;
|
||||
$logblastwasap->tempoh = $this->tempoh;
|
||||
$logblastwasap->status = $response;
|
||||
$logblastwasap->nama = $this->namapengguna;
|
||||
$logblastwasap->save();
|
||||
|
||||
Log::info("ARCC WABOT - Pelanggan SAG Tawarruq".$response);
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class Notis extends Model
|
||||
{
|
||||
protected $table = 'notis';
|
||||
public $timestamps = false;
|
||||
public $timestamps = true;
|
||||
protected $primaryKey = 'id';
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class NotisPeringatan extends Model
|
||||
{
|
||||
protected $table = 'notisperingatan';
|
||||
public $timestamps = false;
|
||||
public $timestamps = true;
|
||||
protected $primaryKey = 'id';
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddOnepercentToLelongTable extends Migration
|
||||
{
|
||||
public function getActiveDB(){
|
||||
$config_db = array_keys(config("database.connections"));
|
||||
|
||||
$db_connection = array_filter($config_db,function($connection){
|
||||
try{
|
||||
if($connection == 'mysql7')
|
||||
return false;
|
||||
|
||||
$db = DB::connection($connection)->getPdo();
|
||||
return true;
|
||||
} catch(\Exception $e){
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return $db_connection;
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach($db_connection as $dbase){
|
||||
Schema::connection($dbase)->table('lelong', function (Blueprint $table) use($dbase) {
|
||||
|
||||
$isUjrahExist = Schema::connection($dbase)->hasColumn('lelong', 'ujrah');
|
||||
$isOnePercentExist = Schema::connection($dbase)->hasColumn('lelong', 'onepercent');
|
||||
$isTagbaruExist = Schema::connection($dbase)->hasColumn('lelong', 'tagujrah');
|
||||
|
||||
|
||||
if(! $isUjrahExist){
|
||||
$table->decimal('ujrah', 9, 2);
|
||||
}
|
||||
|
||||
if(! $isOnePercentExist){
|
||||
$table->decimal('onepercent', 9, 2);
|
||||
}
|
||||
|
||||
if(! $isTagbaruExist){
|
||||
$table->tinyInteger('tagujrah')->default(0);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach($db_connection as $dbase){
|
||||
$columns = ['ujrah', 'onepercent','tagujrah'];
|
||||
|
||||
|
||||
$columns_exist = array_filter($columns,function($column) use($dbase){
|
||||
return Schema::connection($dbase)->hasColumn('lelong', $column);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('lelong', function(Blueprint $table) use($columns_exist){
|
||||
foreach($columns_exist as $column){
|
||||
$table->dropColumn($column);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddTagnotisToGadaiTable extends Migration
|
||||
{
|
||||
public function getActiveDB(){
|
||||
$config_db = array_keys(config("database.connections"));
|
||||
|
||||
$db_connection = array_filter($config_db,function($connection){
|
||||
try{
|
||||
if($connection == 'mysql7')
|
||||
return false;
|
||||
|
||||
$db = DB::connection($connection)->getPdo();
|
||||
return true;
|
||||
} catch(\Exception $e){
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return $db_connection;
|
||||
}
|
||||
|
||||
public function up()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach($db_connection as $dbase){
|
||||
Schema::connection($dbase)->table('gadai', function (Blueprint $table) use($dbase) {
|
||||
|
||||
$isTagNotisExist = Schema::connection($dbase)->hasColumn('gadai', 'tagnotis');
|
||||
|
||||
|
||||
if(! $isTagNotisExist){
|
||||
$table->tinyInteger('tagnotis')->default(0);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach($db_connection as $dbase){
|
||||
$columns = ['tagnotis'];
|
||||
|
||||
|
||||
$columns_exist = array_filter($columns,function($column) use($dbase){
|
||||
return Schema::connection($dbase)->hasColumn('gadai', $column);
|
||||
});
|
||||
|
||||
Schema::connection($dbase)->table('gadai', function(Blueprint $table) use($columns_exist){
|
||||
foreach($columns_exist as $column){
|
||||
$table->dropColumn($column);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddNamaToTableLogBlastWasap extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('log_blast_wasap', function (Blueprint $table) {
|
||||
$table->text('nama')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('log_blast_wasap', function (Blueprint $table) {
|
||||
$table->dropColumn(['nama']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddNamaToTableLogBlastSms extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('log_blast_sms', function (Blueprint $table) {
|
||||
$table->text('nama')->nullable();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('log_blast_sms', function (Blueprint $table) {
|
||||
$table->dropColumn(['nama']);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -839,5 +839,7 @@ $router->group(['prefix'=>'arcc'], function () use ($router){
|
||||
$router->get('senarainotisperingatan',['uses'=>'CallCenterController@senarainotisperingatan']);
|
||||
$router->get('getcawnotis/{notisid}',['uses'=>'CallCenterController@getcawnotis']);
|
||||
$router->get('getcawnotisbycaw',['uses'=>'CallCenterController@getcawnotisbycaw']);
|
||||
$router->get('bycawnotisperingatan/{kodcaw}/{notisid}',['uses'=>'CallCenterController@bycawnotisperingatan']);
|
||||
$router->post('blastwasapbysag',['uses'=>'CallCenterController@blastwasapbysag']);
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user