Reputation: 396
In my composer I pass list of data as :
$evens = Even::all()->paginate(10);
$view->with('evens', $evens);
But now I want to also pass if the post is liked by the user or not with:
$likes = Inspiring::select('even_id')->where('user_id', Auth::user()->id)->get();
$likeArr = array_flatten($likes->toArray());
And than activate a class depending on if user liked the post or not
But when I use with
I can only send one collection of data. I wonder how I can san this data as collection or pass it as adding $likeArr
into $even
Upvotes: 0
Views: 22
Reputation: 7509
Pass an array
return $view->with(['evens' => $evens, 'likeArr' => $likeArr]);
Upvotes: 3