Print laravel inquiries

1

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.

this is what I want to do

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?

    
asked by Alberico Kmpos 06.10.2018 в 01:41
source

1 answer

0

With the code you have you can use the variables that you pass in the compact to the view.

In this case you are passing two: "InquiryVisit" and "areas", then in the view you can use them, as a normal variable $ ConsultaVisita and $ areas.

    
answered by 07.10.2018 в 05:53