Bulletinboard/database/seeders/DatabaseSeeder.php

98 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2021-02-24 09:01:35 +00:00
<?php
namespace Database\Seeders;
use App\Models\Occupation;
use App\Models\Post;
use App\Models\Role;
use App\Models\Status;
use App\Models\TimePeriod;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
$roles= [
[
'name' => 'User'
],
[
'name' => 'Admin'
]
];
foreach ($roles as $role){
Role::firstOrCreate($role);
}
// User::factory()->create([
// 'name' => 'admin',
//// 'email' => 'admin@thismail.com',
// 'username' => 'seba4928',
// 'password' => Hash::make('Aa123456&'),
// 'role_id' => Role::where("name","Admin")->first()->id
// ]);
// User::factory()->create([
// 'name' => 'user',
// 'username' => 'seba4929',
// 'password' => Hash::make('Aa123456&'),
// 'role_id' => Role::where("name","User")->first()->id
// ]);
// \App\Models\User::factory(10)->create();
$statuses = [
[
'name' => 'Pending'
],
[
'name' => 'Looking for collaborator'
],
[
'name' => 'Collaborator Found'
]
];
foreach ($statuses as $status){
Status::firstOrCreate($status);
}
$occupations =[
[
'name' => 'IT-Supporter'
],
[
'name' => 'Datatekniker med Infrastruktur'
],
[
'name' => 'Datatekniker med Programmering'
]
];
foreach ($occupations as $occupation){
Occupation::firstOrCreate($occupation);
}
$timePeriods = [
[
'name' => 'Timer'
],
[
'name' => 'Arbejdsdage'
],
[
'name' => 'Uge'
],
[
'name' => 'Måneder'
]
];
foreach ($timePeriods as $timePeriod){
TimePeriod::firstOrCreate($timePeriod);
}
//Post::factory(20)->create();
}
}