database/seeds/RolesPermissionsSeeder.php
/**
     * Create a user with given role
     *
     * @param $role
     */
Create a user with given role
@param $role
Create a user with given role @param $role
private function createUser($role)
    {
        $name = $role->name;
        $isVendor = $role->name === Role::VENDOR;
        $username = strtolower(Str::slug($name, '_'));
        $user = factory(App\User::class)
            ->create([
                'username' => $username,
                'email' => Str::slug($name , '_'). '@example.com',
                'first_name' => $name,
                'last_name' => '',
                'is_vendor' => $isVendor,
                'is_active' => true
            ]);
        if (!$isVendor ) {
            $user->internalUser()
                ->save(factory(App\InternalUser::class)
                    ->make(['user_id' => $user->id]));
        } else {
            $address = Address::createDefaultAddress();
            $user->vendor()
                ->save(factory(App\Vendor::class)
                    ->make(['user_id' => $user->id,
                        'business_name' => 'Vendor',
                        'rc_number' => '',
                        'tax_identification_number' => '',
                        'address_id' => $address->id,
                        'email' => '-',
                        'business_description' => '-',
                        'website' => '',
                        'is_default' => true
                    ]));
        }
        $user->assignRole($name);
        if ($name == Role::SYSADMIN) {
            $this->command->info('Here is the super admin details to login:');
            $this->command->warn('Super Admin Username: \'' . $name . '@example.com\'');
            $this->command->warn('Password: \'default123\'' . "\n");
        }
    }
private function createUser ( $ role ) { $ name = $ role -> name ; $ isVendor = $ role -> name === Role :: VENDOR ; $ username = strtolower ( Str :: slug ( $ name , '_' ) ) ; $ user = factory ( App \ User :: class ) -> create ( [ 'username' => $ username , 'email' => Str :: slug ( $ name , '_' ) . '@example.com' , 'first_name' => $ name , 'last_name' => '' , 'is_vendor' => $ isVendor , 'is_active' => true ] ) ; if ( ! $ isVendor ) { $ user -> internalUser ( ) -> save ( factory ( App \ InternalUser :: class ) -> make ( [ 'user_id' => $ user -> id ] ) ) ; } else { $ address = Address :: createDefaultAddress ( ) ; $ user -> vendor ( ) -> save ( factory ( App \ Vendor :: class ) -> make ( [ 'user_id' => $ user -> id , 'business_name' => 'Vendor' , 'rc_number' => '' , 'tax_identification_number' => '' , 'address_id' => $ address -> id , 'email' => '-' , 'business_description' => '-' , 'website' => '' , 'is_default' => true ] ) ) ; } $ user -> assignRole ( $ name ) ; if ( $ name == Role :: SYSADMIN ) { $ this -> command -> info ( 'Here is the super admin details to login:' ) ; $ this -> command -> warn ( 'Super Admin Username: \'' . $ name . '@example.com\'' ) ; $ this -> command -> warn ( 'Password: \'default123\'' . " \n " ) ; } }
Create a user with given role
 @param $role
Create a user with given role @param $role