public function run()
 {
     $admin = array('name' => 'admin', 'email' => '*****@*****.**', 'password' => bcrypt('kagiadmin'), 'activated_at' => date("Y-m-d H:i:s"), 'created_at' => date("Y-m-d H:i:s"), 'blocked' => 0, 'banned' => 0, 'confirmed' => 1, 'activated' => 1, 'confirmation_code' => md5(microtime() . Config::get('app.key')), 'avatar' => 'assets/images/usr.png');
     $user = array('name' => 'user', 'email' => '*****@*****.**', 'password' => bcrypt('kagiuser'), 'activated_at' => date("Y-m-d H:i:s"), 'created_at' => date("Y-m-d H:i:s"), 'blocked' => 0, 'banned' => 0, 'confirmed' => 1, 'activated' => 1, 'confirmation_code' => md5(microtime() . Config::get('app.key')), 'avatar' => 'assets/images/usr.png');
     $permissions = array(['name' => 'Manage Admin', 'slug' => 'manage_admin', 'description' => 'Give permission to user to access the admin area.'], ['name' => 'Manage Own Data', 'slug' => 'manage_own', 'description' => 'Allow users to manage their own data.']);
     $roles = array(['name' => 'Admin', 'slug' => 'admin', 'description' => 'Give user full permission to site functions.'], ['name' => 'User', 'slug' => 'user', 'description' => 'Standard User']);
     // Create Permissions
     DB::table('permissions')->delete();
     $statement = "ALTER TABLE permissions AUTO_INCREMENT = 1;";
     DB::unprepared($statement);
     DB::table('permissions')->insert($permissions);
     // Create Roles
     DB::table('roles')->delete();
     $statement = "ALTER TABLE roles AUTO_INCREMENT = 1;";
     DB::unprepared($statement);
     DB::table('roles')->insert($roles);
     // Clear relationships
     DB::table('permission_role')->delete();
     $statement = "ALTER TABLE permission_role AUTO_INCREMENT = 1;";
     DB::unprepared($statement);
     DB::table('role_user')->delete();
     $statement = "ALTER TABLE role_user AUTO_INCREMENT = 1;";
     DB::unprepared($statement);
     // Create Users
     DB::table('users')->delete();
     $statement = "ALTER TABLE users AUTO_INCREMENT = 1;";
     DB::unprepared($statement);
     DB::table('users')->insert($admin);
     DB::table('users')->insert($user);
     // Attach permission to role
     $role = $this->role->find(1);
     $role->syncPermissions([1]);
     $role = $this->role->find(2);
     $role->syncPermissions([2]);
     // Attach role to user
     $user = User::find(1);
     $user->roles()->attach(1);
     $user = User::find(2);
     $user->roles()->attach(2);
 }
Exemple #2
0
 public function findByUsernameOrCreateGoogle($userData)
 {
     //dd($userData);
     //	protected $fillable = ['name', 'email', 'password', 'blocked', 'banned', 'confirmed', 'activated'];
     if ($userData->name == null) {
         $userData->name = $userData->nickname;
     }
     if ($userData->email == null) {
         $userData->email = $userData->nickname;
     }
     if ($userData->avatar == null) {
         $userData->avatar = Config::get('kagi.kagi_avatar', 'assets/images/usr.png');
     }
     $date = date("Y-m-d H:i:s");
     $name = $userData->name;
     $email = $userData->email;
     $avatar = $userData->avatar;
     $check = $this->checkUserExists($name, $email);
     //dd($check);
     if ($check == null) {
         User::firstOrCreate(['name' => $name, 'email' => $email, 'avatar' => $avatar, 'activated_at' => date("Y-m-d H:i:s"), 'blocked' => 0, 'banned' => 0, 'confirmed' => 1, 'activated' => 1, 'activated_at' => $date, 'last_login' => $date, 'avatar' => $avatar, 'confirmation_code' => md5(microtime() . Config::get('app.key'))]);
         $check_again = $this->checkUserExists($name, $email);
         //dd($check_again->id);
         $user = $this->user->find($check_again->id);
         $user->syncRoles([Config::get('kagi.default_role')]);
         \Event::fire(new \ProfileWasCreated($check_again));
         \Event::fire(new \EmployeeWasCreated($check_again));
         return User::firstOrCreate(['name' => $name, 'email' => $email]);
     } else {
         //dd($check);
         $this->touchLastLogin($check->id);
         return User::firstOrCreate(['name' => $name, 'email' => $email]);
     }
 }
Exemple #3
0
 /**
  * Change the user confirm status
  *
  * @param  $user
  *
  * @return
  */
 public function activateUser($user)
 {
     //dd($user);
     $user = User::find($user->id);
     if ($user != null) {
         $user->activated = 1;
         $user->activated_at = date("Y-m-d H:i:s");
         return $user->update();
     } else {
         return;
     }
 }