我有点搞不懂拉维尔Eloquent 资源和变形金刚之间的区别.我什么时候应该使用资源,什么时候应该使用变压器.从laravel documentation年到medium article年对其进行了一些研究,但其目的似乎相同.
May be i have wrong concept about that. Any knowledge share from anyone will be appreciate.
我有点搞不懂拉维尔Eloquent 资源和变形金刚之间的区别.我什么时候应该使用资源,什么时候应该使用变压器.从laravel documentation年到medium article年对其进行了一些研究,但其目的似乎相同.
May be i have wrong concept about that. Any knowledge share from anyone will be appreciate.
Laravel Eloquent API Resource was released on Laravel 5.5.
在这个功能正式存在之前,Spatiale有一个名为spatie/laravel-fractal
的包,它是league/fractal
的包装.
Both packages archives the same objective with different approach.
I prefer using the Eloquent API Resource since it's embedded on Laravel, so I reduce one (direct) dependency.
Note: The medium article uses the Fractal
package, but this article is very superficial, you can find more detailed instructions on spatie/laravel-fractal
, it you decide to use it.