I assume that this should all be in one query in order to prevent duplicate data in the database. Is this correct?
How do I simplify this code into one Eloquent query?
$user = User::where( 'id', '=', $otherID )->first();
if( $user != null )
if( $user->requestReceived() )
accept_friend( $otherID );
else if( !$user->requestSent() )
$friend = new Friend;
$friend->user_2 = $otherID;
$friend->accepted = 0;