如何将变量从blade传递到LARAVEL命令
我需要将用户id从blade传递到routes,然后将该变量用于laravel命令。我该怎么办 lista_lavori.blade.php StampaSingoloReport.php-命令 您可以传递一个数组来调用如下方法如何将变量从blade传递到LARAVEL命令,laravel,laravel-5,Laravel,Laravel 5,我需要将用户id从blade传递到routes,然后将该变量用于laravel命令。我该怎么办 lista_lavori.blade.php StampaSingoloReport.php-命令 您可以传递一个数组来调用如下方法 Route::get('/stampasingoloreport/{id}', function ($id) { Artisan::call('StampaSingoloReport:stampasingoloreport',[ 'id' =>
Route::get('/stampasingoloreport/{id}', function ($id) {
Artisan::call('StampaSingoloReport:stampasingoloreport',[
'id' => $id
]);
return back();
});
现在在handle方法中,您可以访问以下参数
protected $signature = 'StampaSingoloReport:stampasingoloreport { id } ' ;
function handle(){
$this->argument('id');
// your code
}
希望这有帮助levaral我遇到了这个错误id参数不存在。@CarmineRub您是否使用了答案中提供的代码?levaral是,但不起作用!你能给我看看刀片中的href=吗?please.Artisan::call'StampaSingoloReport:StampaSingoloReport',['id'=>$id];此代码将使用argumentsfunction句柄{$this->argument'id';//您的代码}运行命令。此函数将接收参数
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') ;
});
}
Route::get('/stampasingoloreport/{id}', function ($id) {
Artisan::call('StampaSingoloReport:stampasingoloreport',[
'id' => $id
]);
return back();
});
protected $signature = 'StampaSingoloReport:stampasingoloreport { id } ' ;
function handle(){
$this->argument('id');
// your code
}