Fixed UserSeeder.php.
This commit is contained in:
parent
2409fec66e
commit
7f91e76d90
|
@ -25,7 +25,7 @@ class ResourceController extends Controller
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\User;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class UserSeeder extends Seeder
|
class UserSeeder extends Seeder
|
||||||
|
@ -11,6 +12,13 @@ class UserSeeder extends Seeder
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(User::findByName("admin"))
|
||||||
|
return;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
$user = new \App\User();
|
$user = new \App\User();
|
||||||
|
|
||||||
$user->name_first = "admin";
|
$user->name_first = "admin";
|
||||||
|
@ -19,6 +27,8 @@ class UserSeeder extends Seeder
|
||||||
$user->setPasswordAttribute("1234");
|
$user->setPasswordAttribute("1234");
|
||||||
$user->phone = 12345678;
|
$user->phone = 12345678;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (\Spatie\Permission\Models\Permission::all() as $permission) {
|
foreach (\Spatie\Permission\Models\Permission::all() as $permission) {
|
||||||
$user->givePermissionTo($permission);
|
$user->givePermissionTo($permission);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue