feat: add provider model and bridging schemas
This commit is contained in:
32
app/Models/Provider.php
Normal file
32
app/Models/Provider.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Provider extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'providers';
|
||||
|
||||
protected $fillable = [
|
||||
'organization_id',
|
||||
'username',
|
||||
'password',
|
||||
'code',
|
||||
'status',
|
||||
'header_token',
|
||||
'token',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
];
|
||||
|
||||
public function organization()
|
||||
{
|
||||
return $this->belongsTo(Organization::class, 'organization_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -272,6 +272,11 @@ class RequestLog extends Model
|
||||
return $this->belongsTo(Service::class, 'service_code', 'code');
|
||||
}
|
||||
|
||||
public function plan()
|
||||
{
|
||||
return $this->belongsTo(Plan::class, 'plan_id');
|
||||
}
|
||||
|
||||
public function requestLogBenefits()
|
||||
{
|
||||
return $this->hasMany(RequestLogBenefit::class, 'request_log_id');
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('providers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('organization_id')->constrained('organizations')->cascadeOnDelete();
|
||||
$table->string('username');
|
||||
$table->string('password');
|
||||
$table->string('code')->nullable();
|
||||
$table->string('status')->default('active');
|
||||
$table->string('header_token', 255)->nullable();
|
||||
$table->string('token', 255)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['organization_id', 'username']);
|
||||
$table->index(['organization_id', 'code', 'status']);
|
||||
$table->index('token');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('providers');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('request_logs', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('request_logs', 'plan_id')) {
|
||||
$table->unsignedBigInteger('plan_id')->nullable()->after('member_id');
|
||||
$table->index('plan_id');
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('request_logs', 'admission_date')) {
|
||||
$table->dateTime('admission_date')->nullable()->after('submission_date');
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('request_logs', 'nomor_sep')) {
|
||||
$table->string('nomor_sep')->nullable()->after('keterangan');
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('request_logs', 'status_rujukan')) {
|
||||
$table->string('status_rujukan')->nullable()->after('nomor_sep');
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('request_logs', 'nomor_rujukan')) {
|
||||
$table->string('nomor_rujukan')->nullable()->after('status_rujukan');
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('request_logs', 'no_transaksi_provider')) {
|
||||
$table->string('no_transaksi_provider')->nullable()->after('nomor_rujukan');
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('request_logs', 'inacbgs_code')) {
|
||||
$table->string('inacbgs_code')->nullable()->after('no_transaksi_provider');
|
||||
}
|
||||
|
||||
if (!Schema::hasColumn('request_logs', 'inacbgs_amount')) {
|
||||
$table->decimal('inacbgs_amount', 18, 2)->nullable()->after('inacbgs_code');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('request_logs', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('request_logs', 'inacbgs_amount')) {
|
||||
$table->dropColumn('inacbgs_amount');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('request_logs', 'inacbgs_code')) {
|
||||
$table->dropColumn('inacbgs_code');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('request_logs', 'no_transaksi_provider')) {
|
||||
$table->dropColumn('no_transaksi_provider');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('request_logs', 'nomor_rujukan')) {
|
||||
$table->dropColumn('nomor_rujukan');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('request_logs', 'status_rujukan')) {
|
||||
$table->dropColumn('status_rujukan');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('request_logs', 'nomor_sep')) {
|
||||
$table->dropColumn('nomor_sep');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('request_logs', 'admission_date')) {
|
||||
$table->dropColumn('admission_date');
|
||||
}
|
||||
|
||||
if (Schema::hasColumn('request_logs', 'plan_id')) {
|
||||
$table->dropIndex(['plan_id']);
|
||||
$table->dropColumn('plan_id');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user