mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-11 08:04:09 -08:00
29 lines
998 B
PHP
29 lines
998 B
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use App\Models\Department;
|
|
use App\Models\Location;
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class DepartmentSeeder extends Seeder
|
|
{
|
|
public function run()
|
|
{
|
|
Department::truncate();
|
|
|
|
if (! Location::count()) {
|
|
$this->call(LocationSeeder::class);
|
|
}
|
|
|
|
$locationIds = Location::all()->pluck('id');
|
|
|
|
Department::factory()->count(1)->hr()->create(['location_id' => $locationIds->random()]);
|
|
Department::factory()->count(1)->engineering()->create(['location_id' => $locationIds->random()]);
|
|
Department::factory()->count(1)->marketing()->create(['location_id' => $locationIds->random()]);
|
|
Department::factory()->count(1)->client()->create(['location_id' => $locationIds->random()]);
|
|
Department::factory()->count(1)->product()->create(['location_id' => $locationIds->random()]);
|
|
Department::factory()->count(1)->silly()->create(['location_id' => $locationIds->random()]);
|
|
}
|
|
}
|