Closed debuGhy closed 4 years ago
public function ds_participantImg($threadId){
$ds=Models::participant()->where('thread_id', $threadId)->withTrashed()->whereNotIn('user_id', [auth()->user()->id])->first();
$user=User::find($ds->user_id);
if($user->latestImage){
return $user->latestImage->img;
}else{
return asset('placeholder.png');
}
}
Created the above function in Thread model to retrieve the image url.
I tried using $thread->participantsString(Auth::id()) to get the participant name but when I am unable to fetch the user image from another table. How can I achieve it? I have two tables: one is users table(laravel default) and the other is user_images (where user images are stored). I tried using the relationship function as well but it didn't worked out. Can anyone help?