在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):laravel-json-api/laravel开源软件地址(OpenSource Url):https://github.com/laravel-json-api/laravel开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):JSON:API for Web ArtisansImplement feature-rich JSON:API compliant APIs in your Laravel applications. Build your next standards-compliant API today. Why use JSON:API and Laravel JSON:API?Great question! Here's some reasons from this excellent article by Denisa Halmaghi: Why Use JSON:API?
Why use Laravel JSON:API?
class PostSchema extends Schema
{
/**
* The model the schema corresponds to.
*
* @var string
*/
public static string $model = Post::class;
/**
* The maximum include path depth.
*
* @var int
*/
protected int $maxDepth = 3;
/**
* Get the resource fields.
*
* @return array
*/
public function fields(): array
{
return [
ID::make(),
BelongsTo::make('author')->type('users')->readOnly(),
HasMany::make('comments')->readOnly(),
Str::make('content'),
DateTime::make('createdAt')->sortable()->readOnly(),
DateTime::make('publishedAt')->sortable(),
Str::make('slug'),
BelongsToMany::make('tags'),
Str::make('title')->sortable(),
DateTime::make('updatedAt')->sortable()->readOnly(),
];
}
/**
* Get the resource filters.
*
* @return array
*/
public function filters(): array
{
return [
WhereIdIn::make($this),
WhereIn::make('author', 'author_id'),
];
}
/**
* Get the resource paginator.
*
* @return Paginator|null
*/
public function pagination(): ?Paginator
{
return PagePagination::make();
}
} DocumentationSee our website, laraveljsonapi.io TutorialNew to JSON:API and/or Laravel JSON:API? Then the Laravel JSON:API tutorial is a great way to learn! Follow the tutorial to build a blog application with a JSON:API compliant API. InstallationInstall using Composer composer require laravel-json-api/laravel See our documentation for further installation instructions. UpgradingWhen upgrading you typically want to upgrade this package and all our related packages. This is the recommended way: composer require laravel-json-api/laravel --no-update
composer require laravel-json-api/testing --dev --no-update
composer up "laravel-json-api/*" cloudcreativity/json-api-testing Example ApplicationTo view an example Laravel application that uses this package, see the Tutorial Application. LicenseLaravel JSON:API is open-sourced software licensed under the Apache 2.0 License. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论