tambah function notis peringatan dalam arcc dan blast wasap dan sms

This commit is contained in:
Nur Izzati Zulkifli
2023-12-25 15:50:41 +08:00
parent 060218a6af
commit 0011b12e4d
11 changed files with 571 additions and 25 deletions
@@ -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']);
});
}
}