2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
2021-06-10 13:15:52 -07:00
|
|
|
|
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;
|
2023-03-16 18:29:51 -07:00
|
|
|
use App\Models\User;
|
2021-06-10 13:15:52 -07:00
|
|
|
use Illuminate\Database\Seeder;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
class ActionlogSeeder extends Seeder
|
|
|
|
{
|
2021-06-10 13:15:52 -07:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2023-03-16 18:29:51 -07:00
|
|
|
$admin = User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin()->create();
|
|
|
|
|
2023-03-16 15:25:23 -07:00
|
|
|
Actionlog::factory()
|
|
|
|
->count(300)
|
|
|
|
->assetCheckoutToUser()
|
2023-03-16 18:29:51 -07:00
|
|
|
->create(['user_id' => $admin->id]);
|
2023-03-16 15:25:23 -07:00
|
|
|
|
|
|
|
Actionlog::factory()
|
|
|
|
->count(100)
|
|
|
|
->assetCheckoutToLocation()
|
2023-03-16 18:29:51 -07:00
|
|
|
->create(['user_id' => $admin->id]);
|
2021-06-10 13:15:52 -07:00
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|