I'm doing a project, I'm new to php and laravel, what I want to do is when I ask a question to be able to print separately already generating a pdf report or opening a view with that data, I have tried everything and I can not . I share the code and caputuras of what I have.
this is the function that for the queries in the controller
public function consultas(Request $request)
{
$areas = Area::all();
$start = Carbon::parse($request->start)->startOfDay(); //2016-09-29 00:00:00.000000
$end = Carbon::parse($request->end)->endOfDay(); //2016-09-29 23:59:59.000000
$ConsultaVisita = RegistrarVisitas::Nombre($request->nombre)->Departamento($request->departamento)->DateBetween($start, $end)->orderBy('id', 'DESC')->paginate(10);
return view('visitas.consultas')->with(compact('ConsultaVisita', 'areas'));
}
and this is the code in the model use quieryscope for consultations
class RegistrarVisitas extends Model
{
use DateTranslator;
protected $table = 'visitas';
protected $fillable = ['nombre', 'departamento', 'asunto', 'created_at'];
public function scopeNombre($query, $nombre)
{
return $query->where('nombre', 'LIKE', "%$nombre%");
}
public function scopeDepartamento($query, $departamento)
{
return $query->where('departamento', 'LIKE', "%$departamento%");
}
public function scopeDateBetween($query, $start, $end)
{
return $query->whereBetween('created_at', [$start, $end]);
}
}
I hope I have explained what I want to do and can count on your support.
the print query button does not yet do a function and I do not have a code because I do not know how to do it. Any idea how I can do it?