Ich habe eins zu eins Beziehung, die mir mein erforderliches Ergebnis gibt, aber ich bin nicht in der Lage, Ergebnis in meiner Sicht zu zeigen.zeigt Ergebnis von eins zu eins Beziehung Ergebnis in Sicht in Laravel
dies ist mein Controller-Funktion
public function showallProducts()
{ // parent table
$productstock = Product::with('CurrentPrice')->get();
return view('welcome', compact('productstock'));
}
meiner Ansicht
<table>
<tr>
<th>id</th>
<th>name</th>
<th>description</th>
<th>price</th>
</tr>
@foreach ($productstock as $value)
<tr>
<td>
{{--<h4><a href="{{url('Job-Details',$show->id)}}">
{{$show->jobTitle}}</a></h4>--}}
<p>{{ $value->id }}</p>
</td>
<td>
<i class="fa fa-map-marker"></i>
<P>{{ $value->name }}</P>
</td>
<td><span>{{ $value->description }}</span>
</td>
<td><span>{{ $productstock->CurrentPrice->productprice
}}</span>
</td>
</tr>
@endforeach
</table>
seiner geben mir folgende Fehler
Property [CurrentPrice] does not exist on this collection instance
wenn i dd() in Controller i folgendes Ergebnis.
Array
(
[0] => Array
(
[id] => 1
[name] => effertz.org
[description] => Williamson, Kozey and Marks
[created_at] => 2017-11-28 14:01:19
[updated_at] => 2017-11-28 14:01:19
[current_price] => Array
(
[id] => 5
[product_id] => 1
[productprice] => 52
[created_at] => 2017-11-28 14:01:21
[updated_at] => 2017-11-28 14:01:21
)
)
[1] => Array
(
[id] => 2
[name] => gulgowski.biz
[description] => Schaefer, Simonis and Kiehn
[created_at] => 2017-11-28 14:01:19
[updated_at] => 2017-11-28 14:01:19
[current_price] => Array
(
[id] => 6
[product_id] => 2
[productprice] => 99
[created_at] => 2017-11-28 14:01:21
[updated_at] => 2017-11-28 14:01:21
)
)
wie i Ergebnis in Sicht zeigen, und was ist der Grund der oben genannten Fehler, wie es scheint gut
Verwendung existance Scheck wie @if (empty ($ productstock-> Current) // @endif – seravee
zeigt unter Hinweis darauf, aber ich habe Ergebnis wie ich u in meinem Controller über dd zeigt() – raja
haben Sie versucht Current statt Current? – GoatHater