$perPage = env('PAGINATION_APP_NUMBER'); // Number of results per page $page = request()->input('page', 1); // Get the current page from the request $offset = ($page - 1) * $perPage; $bindings = [ 'limit' => $perPage, 'offset' => $offset, ]; $posts= DB::select(" select posts.id as id,content,name,location,tags,image,posts.created_at as created_at from posts,accounts where posts.id_account=accounts.id and type like '".$request->type."' and id_account=".$request->id_account." ORDER BY created_at DESC LIMIT :offset, :limit ",$bindings);