테이블이 비어 있으면 기본 데이터를 표시하려고합니다. 나는 laravel 문서를 검색했고 this을 발견했다. 난 내 show.blade.php
존재하는 경우 데이터 반향
public function show($id)
{
//Get profile data from the user
$user = User::find($id);
return view('gebruiker/show',[
'user' => $user,
]);
}
에 그리고 내 blade
에 데이터를 전송 내 컨트롤러에서
내가 데이터를 표시
@foreach ($user->profile as $profile)
<div class="col-md-12 col-xs-12" align="center">
<h1>{{ $profile->user->name or 'Geen naam' }}
</h1>
<h3>{{ $profile->age or 'Geen leeftijd' }}</h3>
<span>{{ $profile->country or 'Geen land' }}</span>
</div>
<div class="col-md-6 col-xs-6 follow line" align="center">
<h3>
Bezoekers <br/> <span>{{ $profile->visitors or 'Geen bezoekers' }}</span>
</h3>
</div>
<div class="col-md-12 col-xs-12 login_control text-center">
<br>
{{ $profile->profile or 'Geen beschrijving' }}
</div>
@endforeach
는 $profile->age
는 데이터를 표시하지만, 비어 있지 않은 경우 데이터가 존재하지 않는 경우 그냥 아무것도 보여주지 않는다. 내가 도대체 뭘 잘못하고있는 겁니까?
"데이터 없음"을 정의하십시오. –
내 행에는 아무 것도 없습니다. '$ user-> profile'''age'를 vardump 할 때 그것은 비어 있습니다. – twoam
....... empty ?? 덤프 보여줘. –