Dusanka
3 months ago
298
3
Laravel

How can i write shorter this?

Posted 3 months ago by Dusanka
if ($movie->usersWhoWatched()->where('user_id', auth()->user()->id)->exists()) 
{
            return response()->json(['movie' => $movie, 'watched' => true], 200);
}
return response()->json(['movie' => $movie, 'watched' => false], 200);

Please sign in or create an account to participate in this conversation.