snipe-it/database/seeders/ActionlogSeeder.php

43 lines
994 B
PHP
Raw Normal View History

2016-03-25 01:18:05 -07:00
<?php
2021-06-10 13:18:00 -07:00
namespace Database\Seeders;
2016-03-25 01:18:05 -07:00
use App\Models\Actionlog;
2023-03-16 15:25:23 -07:00
use App\Models\Asset;
use App\Models\Location;
use App\Models\User;
use Illuminate\Database\Seeder;
2016-03-25 01:18:05 -07:00
class ActionlogSeeder extends Seeder
{
public function run()
{
Actionlog::truncate();
2023-03-16 15:25:23 -07:00
if (! Asset::count()) {
$this->call(AssetSeeder::class);
}
if (! Location::count()) {
$this->call(LocationSeeder::class);
}
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
2023-03-16 15:25:23 -07:00
Actionlog::factory()
->count(300)
->assetCheckoutToUser()
->create(['user_id' => $admin->id]);
2023-03-16 15:25:23 -07:00
Actionlog::factory()
->count(100)
->assetCheckoutToLocation()
->create(['user_id' => $admin->id]);
2023-03-20 14:18:54 -07:00
Actionlog::factory()
->count(20)
->licenseCheckoutToUser()
->create(['user_id' => $admin->id]);
}
2016-03-25 01:18:05 -07:00
}