40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use App\Models\TrTransaksi;
|
|
use App\Models\TrRegistrasi;
|
|
use App\Models\MsTindakan;
|
|
use App\Models\MsPegawai;
|
|
use Faker\Factory as Faker;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class TrTransaksiSeeder extends Seeder
|
|
{
|
|
public function run()
|
|
{
|
|
// Nonaktifkan foreign key checks
|
|
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
|
|
|
|
// Seeder untuk transaksi
|
|
for ($i = 0; $i < 10; $i++) {
|
|
// Ambil data acak dari tabel yang ada
|
|
$registrasi = rand(1, 200);// Ambil registrasi acak
|
|
$tindakan = rand(1, 200); // Ambil tindakan acak
|
|
$pegawai = rand(1, 200); // Ambil pegawai acak
|
|
|
|
// Buat transaksi
|
|
TrTransaksi::create([
|
|
'IdRegistrasi' => $registrasi,
|
|
'IdTindakan' => $tindakan,
|
|
'JmlTindakan' => rand(1, 5), // Contoh: jumlah tindakan acak antara 1-5
|
|
'IdPegawai' => $pegawai,
|
|
]);
|
|
}
|
|
|
|
// Aktifkan kembali foreign key checks
|
|
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
|
|
}
|
|
}
|