Controller method:
public function edit($id){
$match2 = Match::pluck('team_a_id', 'id');
return view('admin.accept.edit', compact('match2'));
}
And view file:
{{ Form::select('matches_id', $match2, null, ['class' => 'form-control']) }}
And my table:
Table from model Match
(table name: matches):
Table from model Team
(table name: teams):
Table teams
is connected (references) with table matches
( team_a_id
and team_b_id
is connected with table teams
). The select
method with view
returned me only ID
with tables:
I need have team_name
with table teams
not id
.
When I change method pluck:
$match2 = Match::pluck('id', 'id');
And view:
{{ Form::select('matches_id', Team::find($match2)->team_a_id." vs. ".Team::find($match2)->team_b_id, null, ['class' => 'form-control']) }}
Laravel returned error:
Invalid argument supplied for foreach() (View: C:\xampp\htdocs\football\football\resources\views\admin\accept\edit.blade.php)
This is metohd edit so I must have highlighted record that was previously selected.