如何将Laravel5.5的API Resources改写为输出自定义JSON的长尾?
- 内容介绍
- 文章标签
- 相关推荐
本文共计1669个文字,预计阅读时间需要7分钟。
从Laravel 5.5开始,引入了API Resources这一概念。我们先来看一下官方文档是如何定义这个概念的:在构建API时,你可能需要一个位于Eloquent模型和JSON响应之间的转换层。
从Laravel 5.5+开始,加入了API Resources这个概念。
我们先来看一下官网如何定义这个概念的:
When building an API, you may need a transformation layer that sits between your Eloquent models and the JSON responses that are actually returned to your application's users. Laravel's resource classes allow you to expressively and easily transform your models and model collections into JSON.
可能看完这个概念之后,你仍然有点不明白,毕竟这个定义说的有点含糊。
本文共计1669个文字,预计阅读时间需要7分钟。
从Laravel 5.5开始,引入了API Resources这一概念。我们先来看一下官方文档是如何定义这个概念的:在构建API时,你可能需要一个位于Eloquent模型和JSON响应之间的转换层。
从Laravel 5.5+开始,加入了API Resources这个概念。
我们先来看一下官网如何定义这个概念的:
When building an API, you may need a transformation layer that sits between your Eloquent models and the JSON responses that are actually returned to your application's users. Laravel's resource classes allow you to expressively and easily transform your models and model collections into JSON.
可能看完这个概念之后,你仍然有点不明白,毕竟这个定义说的有点含糊。

