This commit is contained in:
R
2022-11-23 13:16:24 +07:00
parent f7d8759a76
commit d5b43d9896
5 changed files with 203 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
<?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('claims', function (Blueprint $table) {
$table->id();
$table->string('code')->index();
$table->foreignId('member_id')->index();
$table->foreignId('diagnosis_id')->index();
$table->string('total_claim');
$table->string('currency');
$table->foreignId('plan_id')->index();
$table->foreignId('benefit_id')->index();
$table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable()->index();
$table->unsignedBigInteger('updated_by')->nullable()->index();
$table->unsignedBigInteger('deleted_by')->nullable()->index();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('claims');
}
};

View File

@@ -0,0 +1,36 @@
<?php
namespace Database\Seeders;
use App\Models\Icd;
use App\Models\Member;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Str;
class DummyClaimSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$members = Member::limit(10)->get();
foreach ($members as $member) {
for ($x = 0; $x < 10; $x++) {
$member->claims()->create([
'code' => Str::random('16'),
'member_id' => $member->id,
'diagnosis_id' => Icd::inRandomOrder()->first()->id,
'total_claim' => 5000000,
'currency' => 'IDR',
'plan_id' => $member->currentPlan->id,
'benefit_id' => $member->currentPlan->benefits()->inRandomOrder()->first()->id,
]);
}
}
}
}