- Complete GGZ Ecademy Laravel backend application - RESTful API for learning products, members, filters - Authentication and authorization system - Database migrations and seeders - Custom CRUD generator commands - Email notification system - Integration with frontend applications
This commit is contained in:
170
database/seeds/UserSeeder.php
Normal file
170
database/seeds/UserSeeder.php
Normal file
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
use App\Repositories\Role;
|
||||
use App\Services\UserService;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Notifications\CustomNotification;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
|
||||
private $userService;
|
||||
|
||||
public function __construct(UserService $userService)
|
||||
{
|
||||
$this->userService = $userService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// $this->userService->truncate();
|
||||
// DB::table('role_user')->truncate();
|
||||
|
||||
$adminRole = Role::where('name', 'admin')->first();
|
||||
$operatorRole = Role::where('name', 'operator')->first();
|
||||
$userRole = Role::where('name', 'user')->first();
|
||||
|
||||
// $demo_notification = new CustomNotification('Subject', 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Ab dolores libero at dolorem unde, consequuntur sed eveniet totam aperiam aspernatur.');
|
||||
|
||||
$admin = factory(App\Repositories\User::class)->create([
|
||||
'first_name' => 'Kees',
|
||||
'last_name' => 'van de Wal',
|
||||
'email' => 'kees@ggzecademy.nl',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
// $url = asset('images/kees.png');
|
||||
$url = 'https://ggzecademy.nl/web/uploads/2019/02/MG_5728-kees2.jpg';
|
||||
|
||||
// $admin->addMediaFromUrl($url)->toMediaCollection('profile_pics');
|
||||
|
||||
$admin->roles()->sync([
|
||||
$adminRole->id,
|
||||
$operatorRole->id,
|
||||
$userRole->id
|
||||
]);
|
||||
|
||||
// $admin->notify($demo_notification);
|
||||
|
||||
$admin = factory(App\Repositories\User::class)->create([
|
||||
'first_name' => 'Maaike',
|
||||
'last_name' => 'Frumau',
|
||||
'email' => 'maaike@3110.nl',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
$admin->roles()->sync([
|
||||
$adminRole->id,
|
||||
$operatorRole->id,
|
||||
$userRole->id
|
||||
]);
|
||||
|
||||
// $admin->notify($demo_notification);
|
||||
|
||||
$admin = factory(App\Repositories\User::class)->create([
|
||||
'first_name' => 'Yongqing',
|
||||
'last_name' => 'Wang',
|
||||
'email' => 'yongqing@3110.nl',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
$admin->roles()->sync([
|
||||
$adminRole->id,
|
||||
$operatorRole->id,
|
||||
$userRole->id
|
||||
]);
|
||||
|
||||
// $admin->notify($demo_notification);
|
||||
|
||||
$admin = factory(App\Repositories\User::class)->create([
|
||||
'first_name' => 'Ingrid',
|
||||
'last_name' => 'Meuwissen',
|
||||
'email' => 'ingridmeuwissen@ggzecademy.nl',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
$admin->roles()->sync([
|
||||
$adminRole->id,
|
||||
$operatorRole->id,
|
||||
$userRole->id
|
||||
]);
|
||||
|
||||
// $admin->notify($demo_notification);
|
||||
|
||||
$operator = factory(App\Repositories\User::class)->create([
|
||||
'first_name' => 'Ingrid',
|
||||
'last_name' => 'van Dijck',
|
||||
'email' => 'ingridvandijck@ggzecademy.nl',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
// $operator->notify($demo_notification);
|
||||
|
||||
$operator->roles()->sync([
|
||||
$operatorRole->id,
|
||||
$userRole->id
|
||||
]);
|
||||
|
||||
$operator = factory(App\Repositories\User::class)->create([
|
||||
'first_name' => 'Margreet',
|
||||
'last_name' => 'Botter',
|
||||
'email' => 'margreet@ggzecademy.nl',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
// $operator->notify($demo_notification);
|
||||
|
||||
$operator->roles()->sync([
|
||||
$operatorRole->id,
|
||||
$userRole->id
|
||||
]);
|
||||
|
||||
$operator = factory(App\Repositories\User::class)->create([
|
||||
'first_name' => 'Marjolijn',
|
||||
'last_name' => 'Tijsmans',
|
||||
'email' => 'marjolijn@ggzecademy.nl',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
// $operator->notify($demo_notification);
|
||||
|
||||
$operator->roles()->sync([
|
||||
$operatorRole->id,
|
||||
$userRole->id
|
||||
]);
|
||||
|
||||
$user = factory(App\Repositories\User::class)->create([
|
||||
'first_name' => 'Inge',
|
||||
'last_name' => 'Jansen',
|
||||
'email' => 'inge@ggzecademy.nl',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
|
||||
// $user->notify($demo_notification);
|
||||
|
||||
// $url = asset('images/inge.jpeg');
|
||||
|
||||
//$user->addMediaFromUrl($url)->toMediaCollection('profile_pics');
|
||||
|
||||
$user->roles()->sync([
|
||||
$userRole->id
|
||||
]);
|
||||
|
||||
|
||||
/**
|
||||
* Creates a fake user
|
||||
*/
|
||||
|
||||
// factory(App\Repositories\User::class, 1)
|
||||
// ->create()
|
||||
// ->each(function ($user) use ($userRole) {
|
||||
// $user->roles()->attach($userRole);
|
||||
// });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user