diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index 8bc9cd0..779cd88 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -83,7 +83,7 @@ class MarhunController extends Controller 'bil' => 1, 'marhun' => $request_data->marhun, 'nota' => $request_data->nota, - 'batu_permata' => $request_data->batu_permata, + 'tag_permata' => $request_data->tag_permata, 'berat_batu_permata' => $request_data->berat_batu_permata, 'karat' => $request_data->karat, 'berat' => $request_data->berat_emas, @@ -168,7 +168,7 @@ class MarhunController extends Controller 'karat' => $request->karat, 'marhun' => $request->marhun, 'nota' => $request->nota, - 'batu_permata' => $request->batu_permata, + 'tag_permata' => $request->tag_permata, 'berat_batu_permata' => $request->berat_batu_permata, 'berat' => $request->berat, 'harga' => $harga['harga'], @@ -202,7 +202,7 @@ class MarhunController extends Controller $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); $marhun = Marhun::on($cawangan['mysql']) - ->select('marhun.norujukan','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai','marhun.batu_permata', 'marhun.berat_batu_permata') + ->select('marhun.norujukan','gadai.nokp','customer.nama','marhun.marhun','marhun.nota','marhun.berat','marhun.karat','marhun.harga','marhun.n_marhun','marhun.t_gadai','marhun.tag_permata', 'marhun.berat_batu_permata') ->rightJoin('gadai', 'gadai.norujukan', '=', 'marhun.norujukan') ->rightJoin('online_arrahn.customer as customer', 'customer.kpbaru','=','gadai.nokp') ->where('marhun.t_gadai','=',$tarikh) diff --git a/app/Marhun.php b/app/Marhun.php index 88eff01..dbbf591 100644 --- a/app/Marhun.php +++ b/app/Marhun.php @@ -15,7 +15,7 @@ class Marhun extends Model * @var array */ protected $fillable = [ - 'kodcaw','marhun','t_gadai','norujukan','bil','nota','karat','berat','harga','n_marhun','batu_permata','berat_batu_permata', + 'kodcaw','marhun','t_gadai','norujukan','bil','nota','karat','berat','harga','n_marhun','tag_permata','berat_batu_permata', ]; /** diff --git a/database/migrations/2024_03_11_085511_alter_batu_permata_column_in_marhun_table.php b/database/migrations/2024_03_11_085511_alter_batu_permata_column_in_marhun_table.php new file mode 100644 index 0000000..ac6ff42 --- /dev/null +++ b/database/migrations/2024_03_11_085511_alter_batu_permata_column_in_marhun_table.php @@ -0,0 +1,76 @@ +getPdo(); + return true; + } catch (\Exception $e) { + return false; + } + }); + return $db_connection; + } + + public function up() + { + $db_connection = $this->getActiveDB(); + + foreach ($db_connection as $dbase) { + $isColumnBatuPermataExist = Schema::connection($dbase)->hasColumn('marhun', 'batu_permata'); + if ($isColumnBatuPermataExist) { + Schema::connection($dbase)->table('marhun', function (Blueprint $table) use ($dbase) { + $table->dropColumn('batu_permata'); + }); + } + Schema::connection($dbase)->table('marhun', function (Blueprint $table) use ($dbase) { + $table->integer('tag_permata')->default(0); + }); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + $db_connection = $this->getActiveDB(); + + foreach ($db_connection as $dbase) { + Schema::connection($dbase)->table('marhun', function (Blueprint $table) use ($dbase) { + $table->dropColumn('tag_permata'); + }); + $isColumnBatuPermataExist = Schema::connection($dbase)->hasColumn('marhun', 'batu_permata'); + if (!$isColumnBatuPermataExist) { + Schema::connection($dbase)->table('marhun', function (Blueprint $table) use ($dbase) { + $table->string('batu_permata')->nullable(); + }); + } + } + } +}