HovedprosjektWebApp/database/seeds/UserSeeder.php

36 lines
809 B
PHP
Raw Normal View History

<?php
use Illuminate\Database\Seeder;
use App\User;
use Illuminate\Support\Facades\Hash;
class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$users = [
'alex' => 'Alex Thomassen',
'martin' => 'Martin Onsrud',
'stian' => 'Stian Larsen',
'oyvind' => 'Øyvind Finsrud',
];
foreach ($users as $username => $name)
{
$user = new User;
$user->username = $username;
$user->name = $name;
$user->email = $username . '@example.com';
$user->password = Hash::make('Kaffekopp123');
2020-03-11 12:57:13 +01:00
$user->admin = $username === 'alex' ? true : false;
$user->save();
}
}
}