Upload single file
This guide is only for the Pro version
Go to Model. Example: app/Models/Category.php
Adding these lines
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
implements HasMedia
class Category extends Model implements Searchable, HasMedia
{
use HasFactory, InteractsWithMedia;
...
Go to file: resources/views/admin/categories/fields.blade.php
Adding x-admin.image-field
component
<div class="form-group mb-3">
<div>{!! Html::decode(Form::label('image', 'Attach an image')) !!}</div>
<x-admin.image-field name='image' :attachable=$resource alt="Alt string" />
</div>
You can add an Image column to the Resource index page
Example: resources/views/admin/categories/table.blade.php
<td>
<img class="img-thumbnail"
alt="{{ $category->name }}"
src="{{ resource_image_url($category) }}"
width="48"
/>
</td>