我正在开发一个API,对于索引路由,我返回分页,但是现在我应该使用有说服力的资源,但是这两者的分页JSON结构是不同的,并且前端代码不再工作。 我的代码是: // AdminUserController.php
public function index()
{
return User::paginate();
}
// ClientUserController.php
public function index()
{
return new UserCollection(User::paginate());
} 第一个JSON结构如下: {
"total
我有这个资源:
class Job extends JsonResource
{
public function toArray($request)
{
// the quantity of branch this job belongs to
$branchesQuantity = BranchJob::where('job_id', $this->id)->count();
// the quantity of countries this job belons to
$countriesQua
site 我正在从事一个项目(CodeIgniter - PHP MySQL),该项目从Ad_API中获取数据并在我的站点中显示这些列表。API使用负载的数据(~1kb)来讨论每个实体的JSON。我每页显示大约20-30个这样的实体,所以这就是我请求服务器的内容(大约20‘s的数据)。服务器以随机方式提供数据,并且可以通过提供任何标识符来请求单个实体的而不是。
Problem I,现在必须用分页显示更多的结果(200+)。如果是MySQL db,我是在查询黄油,但在这里我做不到。
我的论点--解决方案
jQuery分页:是的,这是一个选项,但同样,我必须同时在用户浏览器上加载所有200个
我创建了一个API并进行了定制。浏览文档时,我尝试了几种方法,但不知何故无法进行分页。你能帮帮我吗? PostResource.php <?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class PostResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
我的FOXX play应用程序中有这段代码
var geodata = new Geodata(
applicationContext.collection('geodata'),
{model: Geodatum}
);
/** Lists of all geodata.
*
* This function simply returns the list of all Geodatum.
*/
controller.get('/', function (req, res) {
var parameters = req.parameters;
我试图在Laravel中对分页查询结果进行排序。我需要做一种排序,在每样东西的末尾降到我的分页变量上。
示例:
//get some data attach to variable
$variable = DB::table('exampletable')
->where('id',$somevariable)
->select('id','name')
->paginate(10);
//this function will send the variable and attach **total** on