2017-08-11 87 views
1

我想发布一个数组和一个变量来查看。这是我的变量。发布数组和变量以查看

$ausgabeSpieltag = $saisonMaxSpieltagEins; 

这里是我的数组和方式,就像我现在发布它来查看。但现在我需要在 - >中添加部分变量。

$spieltagSpiel = Spielplan::where('Spieltag', '=', $ausgabeSpieltag)->where('Abgeschlossen', '=', 0)->get(); 
    foreach($spieltagSpiel as $spieltagSpielOutput){ 
     $heimName = Verein::where('V_ID', '=', $spieltagSpielOutput->Heimmannschaft)->first(); 
     $gastName = Verein::where('V_ID', '=', $spieltagSpielOutput->Gastmannschaft)->first(); 
     $resultData[$spieltagSpielOutput->Spielplan_ID] = $heimName->Name. ' - ' .$gastName->Name; 
    } 
return view('spielplan')->with('alleSpiele', $resultData); 

这里是我的输出刀片

<h3>Dateneingabe</h3> 

{{$ausgabeSpieltag}} 

<div class="row"> 
    <div class="col-6 col-md-4"> 
     <label for="">Spielauswahl</label> 
     <select class="form-control input-sm" name="spiele" id="spiele"> 
     @foreach($alleSpiele as $alleSpieleKey => $alleSpieleName) 
      <option value="{{ $alleSpieleKey }}"> 
       {{ $alleSpieleName }} 
      </option> 
     @endforeach 
     </select> 
    </div> 

    <div class="col-6 col-md-4"> 
     <label for="">Teamauswahl</label> 
     <select class="form-control input-sm" name="spiel" id="spiel"> 
     </select> 
    </div> 

    <div class="col-6 col-md-4"> 
     Hier kommt der Abgeschlossen Button hin 
    </div> 
</div> 

一切工作排除我{{$ ausgabeVariable}}。在变量中只有1个数字,我想在Dateneingabe之后的H3中有这个。

回答

0

你应该很容易在laravel传递多个变量,compact像:

$alleSpiele = $resultData; 
return view('spielplan',compact('alleSpiele','ausgabeSpieltag')); 

希望这对你的工作!

+0

我想拿出刀片{{yourVariable}},但它不会工作英寸这个怎么做? – HansMuff

+0

@HansMuff请向您展示刀片文件{{yourVariable}} –

+0

@HansMuff您的变量意味着您在视图文件中需要使用哪个变量。 –

1

你可以尝试

return view('spielplan')->with('alleSpiele', $resultData)->with('variable',$variable); 

,或者您可以使用紧凑

return view('spielplan')->with(compact('alleSpiele', 'variable')); 

,或者你可以把你的数据withing这样

return view('spielplan')->with('data',['alleSpiele'=>$alleSpiele, 'variable'=>$variable]); 

数组,其中alleSpiele是数组和变量是一个变量,你已经创建

1

您可以将数据发送到查看以下阵列

return view('spielplan',['alleSpiele' => $resultData]);