I am trying to connect to my MySQL DB from a project with Laravel Sail in Docker. The problem is that from Sequel Ace I have no problems with the basic data, localhost, 3306, user + pass but from PhpStorm it tells me that the credentials are incorrect (sail/password). Any ideas what I'm missing in the settings?
TaM's questions
I am making a query to the DB from a view with eloquent to print a table, the case is that it works but before the table, where I have the query, it prints the array.
How should I do the query so that it only saves the data to be used in the table but does not print it on the page?
{{ $zero_users = DB::table('empleados')->where('estado', 0)->get() }}
I need to pass a database field from my controller to print it in a sweetalert modal but I can't get it to print it
The field is captured through a condition:
$nombre_empleado = Empleado::where('codigo_empleado', $asistencia->codigo_empleado)->get('nombre');
But I've tried passing it to the view to print it to swal and it doesn't work either way:
return redirect()->route('home')
->with('store_result', 'nok')
->with('empleado', $nombre_empleado);
In swal I have tried with and without quotes, in a thousand ways but I am not successful...
Swal.fire({
icon: 'success',
title: 'Entrada registrada',
html: 'Hora: ' + moment().format('HH:mm:ss') + '<br>' + ' empleado',
})
Any ideas?
Does anyone who works with adminlte in Laravel know how to activate the "register" route once logged in to the system? I need that only an administrator user can register new users.
I'm doing my first steps in Laravel and migrating a Time Control application originally made in PHP.
The thing is that I have created a CRUD with Crud Generator but in the table where it shows the data I want it to take data from another table in the INNER_JOIN style with pluck when a condition is met.
In the ASSISTANCE table I have a person_code field that should show me some data when it matches the row of EMPLOYEES with a match in the employee_code field.
This is the code I have now but it crashes everywhere and I'm stuck. Any ideas?
public function index()
{
$asistencias = Asistencia::paginate();
$empleados = Empleado::where('codigo_empleado','asistencias.codigo_empleado')->pluck('nombre','apellidos');
return view('asistencia.index', compact('asistencias','empleados'))
->with('i', (request()->input('page', 1) - 1) * $asistencias->perPage());
}
Thanks in advance
I have an array defined to print a datatables but I would like that in the buttons part (position 0 of the array) it would not show the option to delete or deactivate when a specific data type is given, in my case, when the user is administrator cannot be disabled but I don't know how to put a conditional inside the array... Any idea?
My code:
while ($reg=$rspta->fetch_object()) {
$data[]=array(
"0"=>($reg->estado)?'<button class="btn btn-warning btn-xs" onclick="mostrar('.$reg->idusuario.')"><i class="fa fa-pen"></i></button>'.' '.'<button class="btn btn-primary btn-xs" onclick="mostrar_clave('.$reg->idusuario.')"><i class="fa fa-key"></i></button>'.' '.'<button class="btn btn-danger btn-xs" onclick="desactivar('.$reg->idusuario.')"><i class="fas fa-toggle-off"></i></button>':'<button class="btn btn-warning btn-xs" onclick="mostrar('.$reg->idusuario.')"><i class="fa fa-pen"></i></button>'.' '.'<button class="btn btn-primary btn-xs" onclick="mostrar_clave('.$reg->idusuario.')"><i class="fa fa-key"></i></button>'.' '.'<button class="btn btn-success btn-xs" onclick="activar('.$reg->idusuario.')"><i class="fas fa-toggle-off"></i></button>',
"1"=>$reg->nombre,
"2"=>$reg->apellidos,
"3"=>$reg->codigo_persona,
"4"=>$reg->email,
"5"=>"<img src='../../admin/files/usuarios/".$reg->imagen."' height='50px' width='50px'>",
"6"=>$reg->fechacreado,
"7"=>($reg->estado)?'<span class="label bg-green">Activado</span>':'<span class="label bg-red">Desactivado</span>'
);
}
I have a form with the following code:
<form action="" name="formulario" id="formulario" method="POST">
<div class="row">
<div class="form-group col-md-6">
<label for="">Tipo usuario(*):</label>
<select name="idtipousuario" id="idtipousuario" class="form-control selectpicker" required>
</select>
</div>
</div>
</form>
The problem is that it is shown twice, with dropdown before the Select, I am convinced that it is some load of the Select CSS that in theory cancels the dropdown but I have tried everything and I don't know where to go anymore, I am working with adminLTE. Does something happen to you?