/**
  * Seed Role Permissions into the database.
  */
 public function run()
 {
     $countryResearcherRole = Role::select('id')->whereName(config('nrgi.roles.country-researcher.name'))->first();
     $permission_name = ['add-contract', 'edit-contract', 'edit-text', 'complete-text', 'complete-metadata', 'add-annotation', 'edit-annotation', 'complete-annotation'];
     $permissions = Permission::whereIn('name', $permission_name)->get();
     $countryResearcherRole->perms()->sync($permissions);
 }
 /**
  * Seed different Roles into the database.
  */
 public function run()
 {
     foreach (config('nrgi.roles') as $role) {
         if (!Role::where('name', $role['name'])->first()) {
             Role::firstOrCreate($role);
         }
     }
 }
 /**
  * Seed Admin User with Roles
  */
 public function run()
 {
     $admin = User::firstOrCreate(['name' => "admin", 'email' => '*****@*****.**', 'password' => Hash::make('admin123'), 'organization' => '', 'status' => 'true']);
     $adminRole = Role::select('id')->whereName(config('nrgi.roles.superadmin.name'))->first();
     $admin->roles()->sync([$adminRole->id]);
     $researcher = User::firstOrCreate(['name' => "researcher", 'email' => '*****@*****.**', 'password' => Hash::make('researcher123'), 'organization' => '', 'status' => 'true']);
     $researcherRole = Role::select('id')->whereName(config('nrgi.roles.researcher.name'))->first();
     $researcher->roles()->sync([$researcherRole->id]);
     $permission_name = ['add-contract', 'edit-contract', 'edit-text', 'complete-text', 'complete-metadata', 'add-annotation', 'edit-annotation', 'complete-annotation'];
     $permissions = Permission::whereIn('name', $permission_name)->get();
     $researcherRole->perms()->sync($permissions);
 }
 /**
  * Update User detail
  *
  * @param       $user_id
  * @param array $formData
  * @param       $role
  * @return bool
  */
 public function update($user_id, array $formData, $role)
 {
     $user = $this->find($user_id);
     $role = $this->role->where('name', $role)->first();
     if (!empty($formData['password'])) {
         $user->password = $this->hash->make($formData['password']);
     }
     $user->email = $formData['email'];
     $user->organization = $formData['organization'];
     $user->status = $formData['status'];
     $user->name = $formData['name'];
     $user->country = $formData['country'];
     try {
         if ($user->save()) {
             $user->roles()->sync([$role->id]);
             $this->logger->info('User successfully updated.', $formData);
             return true;
         }
         return false;
     } catch (\Exception $e) {
         $this->logger->error($e->getMessage());
         return false;
     }
 }
 /**
  * Get All User Roles
  *
  * @return array
  */
 public function getCountryRoles()
 {
     return $this->role->whereIn('name', config('nrgi.country_role'))->lists('display_name', 'name');
 }