add tag_tebus in gadai
This commit is contained in:
@@ -1131,7 +1131,8 @@ class GadaiController extends Controller
|
||||
$updatehistory = Gadai::on($cawangan['mysql'])
|
||||
->where('norujukan','=',$norujukan)
|
||||
->update(array(
|
||||
'historygadaian' => $request->historygadaian
|
||||
'historygadaian' => $request->historygadaian,
|
||||
'tag_tebus' => $request->jenistebus,
|
||||
));
|
||||
|
||||
return response()->json($updatehistory,200);
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddTagTebusToGadai extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function getActiveDB(){
|
||||
$config_db = array_keys(config("database.connections"));
|
||||
|
||||
$db_connection = array_filter($config_db,function($connection){
|
||||
try{
|
||||
if($connection == 'mysql7' || $connection == 'lelong')
|
||||
return false;
|
||||
|
||||
$db = DB::connection($connection)->getPdo();
|
||||
return true;
|
||||
} catch(\Exception $e){
|
||||
Log::info($connection);
|
||||
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) {
|
||||
|
||||
$isTagTebus = Schema::connection($dbase)->hasColumn('gadai', 'tag_tebus');
|
||||
|
||||
if(! $isTagTebus){
|
||||
$table->char('tag_tebus', 2);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('gadai', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user