Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Route::get("user_mig", function()
- {
- temporalestlaUser::truncate();
- $contr = temporalestlaContractUser::all();
- foreach ($contr as $value)
- {
- $psw = Hash::make($value->id_employee);
- $user = new temporalestlaUser
- ([
- "full_name"=>$value->name_used,
- "user" => $value->id_employee,
- "password" => $psw,
- "perfil" => 1
- ]);
- $user->save();
- }
- });
- public function cargar_datos_users(Request $request)
- {
- $archivo = $request->file('archivo');
- $nombre_original=$archivo->getClientOriginalName();
- $extension=$archivo->getClientOriginalExtension();
- $r1=Storage::disk('archivos')->put($nombre_original, File::get($archivo) );
- $ruta = storage_path('archivos') ."/". $nombre_original;
- if($r1)
- {
- Excel::selectSheetsByIndex(0)->load($ruta, function($hoja)
- {
- $hoja->each(function($fila)
- {
- $pass = Hash::make($fila->empleado);
- $user = new User;
- $user->full_name = $fila->nombreempleado;
- $user->user = $fila->empleado;
- $user->password = $pass;
- $user->perfil = 1;
- $user->save();
- });
- });
- return view("administrator.contracts.adminpayrolls")->with("msj","Usuarios Cargados Correctamente");
- }
- else
- {
- return view("administrator.contracts.adminpayrolls")->with("msj","Error al subir el archivo");
- }
- }
- class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
- {
- use Authenticatable, Authorizable, CanResetPassword;
- protected $table = 'users';
- protected $fillable = ['full_name', 'user', 'password','perfil'];
- protected $hidden = ['password', 'remember_token'];
- }
- <script type="text/javascript">
- $(document).on("submit",".formarchivo",function(e)
- {
- e.preventDefault();
- var formu=$(this);
- var nombreform=$(this).attr("id");
- if(nombreform=="f_cargar_datos_users" ){ var miurl="cargar_datos_users"; var divresul="notificacion_resul_fcdu"}
- var formData = new FormData($("#"+nombreform+"")[0]);
- $.ajax
- ({
- url: miurl,
- type: 'POST',
- data: formData,
- cache: false,
- contentType: false,
- processData: false,
- beforeSend: function()
- {
- $("#"+divresul+"").html($("#cargador_empresa").html());
- },
- success: function(data)
- {
- alert("Usuarios cargados correctamente");
- location.reload(true);
- },
- error: function(data)
- {
- alert("Error al subir usuarios. intente nuevamente");
- location.reload(true);
- }
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement