What I need is that when I click on the "Register Passage" button, in addition to saving the registration, it should print a pdf for me.
The "Store" action does it very well, the problem is that the "pasajeImpreso" action does not execute me.
Both separately if they work.
{!!Form::open(array('url'=>'generar/pasaje','method'=>'POST','autocomplete'=>'off'))!!}
{{Form::token()}}
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<a href="{{URL::action('PasajeController@pasajeImpreso')}}" target="_blank">
<button class="btn btn-md btn-block btn-primary" type="submit">Registrar Pasaje</button>
</a>
</div>
{!!Form::close()!!}
This is my Printedpass() action:
public function pasajeImpreso()
{
$query = DB::table('pasajes as p')
->
$view = \View::make('generar.pasaje.pasajeImpreso')->render();
$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($view);
return $pdf->stream('Pasaje');
}
The route for the PrintedPassenger action is this:
Route::get('pasaje_impreso', ['uses' => 'PasajeController@pasajeImpreso']);
For this purpose I am using the barryvdh/laravel-dompdf package
I solved it, I just had to put the onclick property on the button:
and post a script at the bottom:
the route is the same:
=)
You could easily use javascript to open your pdf, so you would send the request that registers the passage and at the same time you would generate your printed passage.
alternate solution
This way you'll call your controller where you'll store your record and then do a redirect to the other action's route (everything will render on the same page).