我想我以某种方式破坏了我的应用程序,因为我没有注意到这发生了,但是我注意到$ profileUser == auth()-> user()逻辑不起作用,尽管它显然评估为true。当我放入$ profileUser-> name == auth()-> user-> name时,它可以工作,但这不是我想要的。
Route::get('/profiles/{user}', 'ProfileController@profile')->name('profile.profile');
public function profile(User $user, ProfilePost $profilePost, $page = null)
{
$activities = Activity::feed($user);
$bestReplyCountQuery = DB::select(DB::raw("select * from replies inner join threads on threads.best_reply = replies.id where replies.user_id = '$user->id'"));
$bestReplyCount = count($bestReplyCountQuery);
return view('profiles.profile', [
'profileUser' => $user,
'activities' => $activities,
'bestReplyCount' => $bestReplyCount,
]);
}
@if($profileUser == auth()->user())
<div class="user-profile-post-init">
<div class="picture">
<p class="avatar" style="background-color: {{ $profileUser->color }}">
{{ substr($profileUser->name, 0, 1) }}</p>
</div>
<div class="post-wysiwyg">
<form method="POST" action="/profiles/{{ $profileUser->name }}/posts">
{{ csrf_field() }}
<input type="text" placeholder="Update your status...">
<i class="fas fa-pen pen"></i>
<div class="form-trigger">
<textarea name="body" id="user-profile-textarea"></textarea>
<button class="submit" type="submit"><i class="fas fa-reply"></i> Post</button>
</div>
</form>
</div>
</div>
@endif