我嘗試構建一個應該創建數組的函數。我想在我看來這個陣列。 這是函數,我不知道如何構建數組。基於從laravel葉片創建數組php和輸出選項值
public function getSpielplan(){
//$newdata = array (
$spieltagSpiel = Spielplan::where('Spieltag', '=', 1)->get();
foreach($spieltagSpiel as $spieltagSpielOutput){
$heimName = Verein::where('V_ID', '=', $spieltagSpielOutput->Heimmannschaft)->get();
foreach($heimName as $heimNameOutput){
$gastName = Verein::where('V_ID', '=', $heimNameOutput->Gastmannschaft)->get();
foreach($gastName as $gastNameOutput){
//array ($spieltagSpielOutput->Spielplan_ID, $heimNameOutput->Name, $gastNameOutput->Name)
}
}
}
//);
//return view('spielplan')->with('alleSpiele', $newdata);
}
我認爲,這是我的輸出
div class="col-xs-6">
label for="">Spielauswahl/label>
select class="form-control input-sm" name="spiele" id="spiele">
@foreach($alleSpiele as $alleSpieleOutput)
option value="{!! HERE MUST BE SPIELPLAN_ID [array0?]!!}">{{HERE MUST BE NAME [array1?] }}/option>
@endforeach
/select>
/div>
在值必須Spielplan_ID,我認爲必須是陣列[0]的第一列?在選項數組中,我需要名稱數組[1]。我必須改變,這將工作?