Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将变量从blade传递到LARAVEL命令_Laravel_Laravel 5 - Fatal编程技术网

如何将变量从blade传递到LARAVEL命令

如何将变量从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' =>

我需要将用户id从blade传递到routes,然后将该变量用于laravel命令。我该怎么办

lista_lavori.blade.php

StampaSingoloReport.php-命令

您可以传递一个数组来调用如下方法

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
}