mattmangoni / nova-recent-posts
Laravel Nova 的简单最近博客文章卡片
v1.1.0
2018-08-26 12:24 UTC
Requires
- php: >=7.1.0
This package is not auto-updated.
Last update: 2024-09-29 06:25:38 UTC
README
这个包是关于什么的?
这将向您的仪表板添加一个简单的全宽卡片,其中包含最近的文章列表。
显然,您需要已经设置好基本的博客系统才能使用此功能。它只需要一个包含至少一个 title 列的 posts 表,并且与用户有一个一对多关系。
可以更改 posts 模型、关系名称 - 以及其他参数 - 从卡片构造函数。
安装
您可以通过 composer 将此包安装到使用 Nova 的 Laravel 应用中
composer require mattmangoni/nova-recent-posts
接下来,您必须将卡片注册到 Nova 中。这通常在 NovaServiceProvider 的 cards 方法中完成。
// in app/Providers/NovaServiceProvder.php // ... public function cards() { return [ // ... // all the parameters are optional new \Mattmangoni\RecentPosts\RecentPosts( string $authorRelationName = 'user', string $dateFormat = 'Y-m-d', int $postsNumber = 5, string $postModel = 'App\Post', string $userUriKey = 'users' ), ]; }