Beispiel #1
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = new User(['first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'full_name' => $data['first_name'] . ' ' . $data['last_name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     $user->type = 'usuario';
     $user->save();
     return $user;
 }
Beispiel #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(CreateUserRequest $request)
 {
     $data = $request->all();
     $user = new User();
     $user->fill($data);
     $user->full_name = $data['first_name'] . " " . $data['last_name'];
     $user->save();
     if ($data['type'] == 1) {
         $user->attachRole(1);
     } elseif ($data['type'] == 2) {
         $user->attachRole(2);
     }
     $message = "Usuario Creado correctamente";
     Session::flash('success', $message);
     return redirect()->route('admin.users.index');
 }
Beispiel #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     #Sistema de Roles
     #Creando Roles
     $adminRole = Role::create(['name' => 'Administrador', 'slug' => 'admin', 'description' => 'Super Usuario - No tiene limites', 'level' => 1]);
     $operativeRole = Role::create(['name' => 'Operativo', 'slug' => 'operativo', 'description' => 'Usuario estandar - No puede alterar inventario', 'level' => 2]);
     $faker = Faker\Factory::create();
     DB::table('users')->truncate();
     //	factory(App\User::class)->create(array(
     //      'first_name'      =>  'Johan',
     //      'last_name'       =>  'Rueda',
     //		'full_name'		  =>  'Johan Rueda',
     //		'email'		      =>  '*****@*****.**',
     //		'password'	      =>  Hash::make('123456'),
     //		'type'  	      =>  'administrador'
     //	));
     //  factory(App\User::class,49)->create();
     $id_admin = \DB::table('users')->insertGetId(array('first_name' => 'Johan', 'last_name' => 'Rueda', 'full_name' => 'Johan Rueda', 'email' => '*****@*****.**', 'password' => bcrypt('jrrg*4543')));
     $admin_role = User::find($id_admin);
     $admin_role->attachRole($adminRole);
     \DB::table('user_profiles')->insert(array('user_id' => $id_admin, 'bio' => "Administrador Root del sistema", 'website' => 'saludver.dev', 'twitter' => 'https://twitter.com/JjdjJohan'));
     // Usuarios de Prueba:
     for ($i = 0; $i < 3; $i++) {
         $first_name = $faker->name;
         $last_name = $faker->name;
         $id = \DB::table('users')->insertGetId(array('first_name' => $first_name, 'last_name' => $last_name, 'full_name' => $first_name . ' ' . $last_name, 'email' => $faker->unique()->email, 'password' => bcrypt('123456')));
         \DB::table('user_profiles')->insert(array('user_id' => $id, 'bio' => $faker->paragraph(rand(2, 5)), 'website' => '', 'twitter' => ''));
         $operative_role = User::find($id);
         $operative_role->attachRole($operativeRole);
     }
 }
Beispiel #4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function assignType($type, $id)
 {
     $user = User::find($id);
     $user->attachRole($type);
     return redirect()->route('admin.users.index');
 }
Beispiel #5
0
 public static function filterAndPaginate($name, $type)
 {
     $user = User::select('users.id', 'users.full_name as full_name', 'email', 'role_user.role_id as role_id', 'roles.name as role_name', 'slug', 'description as role_description', 'level as role_level')->name($name)->type($type)->paginate(10);
     // dd($user);
     return $user;
 }