wqa/nova-page-flexible-models
Composer 安装命令:
composer require wqa/nova-page-flexible-models
包简介
A Laravel Nova package to allow relating models as flexible content to pages
README 文档
README
A package for Laravel Nova which extends Nova Page and Nova Flexible Content and enables you to relate Laravel models to your Nova Pages using Flexible Content.
Installation
composer require wqa/nova-page-flexible-models
Usage
In your page template class you must include the HasFlexibleModels trait.
To add a flexible model field, use the addFlexibleModelField method in your fields definition.
You can use the getFlexibleModels method to get the models back from the page. It's useful to do this using a helper method as shown below to keep your blade files clean.
class AboutPage extends Template { use WQA\NovaPageFlexibleModels\HasFlexibleModels; public function fields(Request $request) { return [ Panel::make('Tesimonials', [ $this->addFlexibleModelField('Testimonials', 'testimonials', Testimonial::class, 'author'), ]) ]; } public function testimonials(): Collection { return $this->getFlexibleModels('testimonials', Testimonial::class); } }
To access the testimonials in a blade view you can call the helper method as above which will give you a collection of whichever model you have specified.
@foreach (Page::testimonials() as $testimonial) <blockquote> {{ $testimonial->body }} <cite>{{ $testimonial->author }}</cite> </blockquote> @endforeach
统计信息
- 总下载量: 381
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-05
