I try to build a function which should create an array. This array I want to put out in my view. This is the function, Im not sure how to build the array.
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);
}
In my view based on blade from laravel, this will be my output
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>
In the value must be Spielplan_ID, I think must be the first column of the array [0]? And in the option array I need Name array [1]. What I have to change that this will work?