mercredi 7 mars 2018

How to pass variable from blade to LARAVEL commands

I need to pass user_id from blade to routes, and then use the variable into a laravel command. How can I do?

lista_lavori.blade.php

<div class="box-tools">
     <a href="/stampasingoloreport/" class="btn btn-box-tool" role="button"><i class="fa fa-print"></i></a>
</div>

web.php - route

Route::get('/stampasingoloreport/{id}', function () {
    Artisan::call('StampaSingoloReport:stampasingoloreport');
    return back();
});

StampaSingoloReport.php - Commands

public function handle()
{

    // static id i need to change this dinamically
    $id = 5;
    $utente = \App\User::where('id',$id)->get();

    //invio email per avvertire l'utente
    $data = array('utenti'=>$utente);
    Mail::send('mail.invioMailReportLavoriSingoli', $data, function($message) {
        $message->to('rubertocarmine94@gmail.com', 'Admin Risorse Umane') ->subject('Email da piattaforma BancaStatoHR') ;
        $message->from('rubertocarmine94@gmail.com') ;
    });

}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2oUidBw
via IFTTT

Aucun commentaire:

Enregistrer un commentaire