App\Http\Controllers\API\ChatController::messages PHP Method

messages() public method

public messages ( )
    public function messages()
    {
        $channel_ids = array_map('intval', explode(',', Request::input('channels')));
        $since = intval(Request::input('since'));
        $limit = min(50, intval(Request::input('limit', 50)));
        $channels = Channel::whereIn('channel_id', $channel_ids)->get()->filter(function ($channel) {
            return priv_check('ChatChannelRead', $channel)->can();
        });
        $messages = Message::whereIn('channel_id', $channel_ids)->with('user');
        if ($since) {
            $messages = $messages->where('message_id', '>', $since);
        }
        $collection = json_collection($messages->orderBy('message_id', $since ? 'asc' : 'desc')->limit($limit)->get(), new MessageTransformer());
        return $since ? $collection : array_reverse($collection);
    }