我有点想知道我做错了什么。我试图使用spatie/laravel-mediallibrary & ebess/advanced-nova-media-library连同nova-flexible-content在nova它工作得很好,但不能让图像显示在我的刀片。如果有人有任何建议或知道我做错了什么。提前感谢您的时间:)我也遵循了那里的指南:https://whitecube.github.io/nova-flexible-content/#/?id=usage-with-ebessadvanced-nova-media-library
我的布局如下所示:
<?php
namespace App\Nova\Flexible\Layouts;
use Whitecube\NovaFlexibleContent\Layouts\Layout;
use Spatie\MediaLibrary\HasMedia;
use Ebess\AdvancedNovaMediaLibrary\Fields\Images;
use Whitecube\NovaFlexibleContent\Concerns\HasMediaLibrary;
class Image extends Layout implements HasMedia
{
use HasMediaLibrary;
protected $name = 'image';
protected $title = 'Image';
public function fields()
{
return [
Images::make('Image', 'images'),
];
}
}
我的模特:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Whitecube\NovaFlexibleContent\Concerns\HasFlexible;
class Job extends Model implements HasMedia
{
use HasFactory;
use HasFlexible;
use InteractsWithMedia;
protected $guareded = [];
protected $casts = [
'publish_date' => 'date',
];
}
控制器:
public function show(Job $job)
{
return view('jobs.show', compact('job'));
}
刀片:
@foreach ($job->flexible('content') as $block)
{{ $block->getMedia('images') }}
@endforeach
composer :
"ebess/advanced-nova-media-library": "^4.0",
"spatie/laravel-medialibrary": "^10.0.0",
"whitecube/nova-flexible-content": "^1.0"
1条答案
按热度按时间erhoui1w1#
下面的答案也可以在相关的Github问题中找到。
我刚刚解决了我的问题,那就是我选错了类。
让我再解释一下:
之前
∮ ∮之后∮
结论
如果您像我一样使用自定义布局类,则需要强制转换正确的类。