Ekapp/skolehjem/database/seeds/UserSeeder.php

39 lines
722 B
PHP

<?php
use App\User;
use Illuminate\Database\Seeder;
class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
try {
if(User::findByName("admin"))
return;
} catch (Exception $e) {
}
$user = new \App\User();
$user->name_first = "admin";
$user->name_last = "admin";
$user->email = "admin@admin.local";
$user->setPasswordAttribute("1234");
$user->phone = 12345678;
foreach (\Spatie\Permission\Models\Permission::all() as $permission) {
$user->givePermissionTo($permission);
}
$user->save();
}
}