craftable: Media Upload for the lastest craftable version updates is not working, old documentation not showing the changes...
I tried many times to create the media upload cover and gallery but it seems that in the new craftable version things changed for this but there is no update information regarding media upload yet for the form-elements.blade…
I have made the changes in post like stated here:
https://docs.getcraftable.com/v4/#/upgrade-guide
but anyway I get these errors:
"Class App\Models\Post contains 11 abstract
methods and must therefore be declared abstract or implement the remaining methods (Spatie\MediaLibrary\HasMedia\HasMedia::media,
Spatie\MediaLibrary\HasMedia\HasMedia::addMedia,
Spatie\MediaLibrary\HasMedia\HasMedia::copyMedia, ...) ◀"
here the Model:
<?php
namespace App\Models;
//use Brackets\Media\HasMedia\HasMediaCollections;
//use Brackets\Media\HasMedia\HasMediaCollectionsTrait;
//use Brackets\Media\HasMedia\HasMediaThumbsTrait;
use Illuminate\Database\Eloquent\Model;
//use Spatie\MediaLibrary\HasMedia\Interfaces\HasMediaConversions;
use Spatie\MediaLibrary\HasMedia\HasMedia;
use Spatie\MediaLibrary\Models\Media;
//use Spatie\MediaLibrary\Media;
use Brackets\Media\HasMedia\ProcessMediaTrait;
use Brackets\Media\HasMedia\AutoProcessMediaTrait;
class Post extends Model implements HasMedia
{
use AutoProcessMediaTrait;
use ProcessMediaTrait;
protected $fillable = [
"title",
"perex",
"published_at",
"enabled",
"author_id",
];
protected $hidden = [
];
protected $dates = [
"published_at",
"created_at",
"updated_at",
];
protected $appends = ['resource_url'];
/* ************************ ACCESSOR ************************* */
public function getResourceUrlAttribute()
{
return url('/admin/posts/'.$this->getKey());
}
public function registerMediaCollections()
{
$this->addMediaCollection('cover')
->accepts('image/*');
$this->addMediaCollection('gallery')
->accepts('image/*')
->maxNumberOfFiles(20);
$this->addMediaCollection('pdf')
->accepts('application/pdf');
}
public function registerMediaConversions(Media $media = null)
{
$this->autoRegisterThumb200();
}
/* ************************ RELATIONS ************************* */
public function author()
{
return $this->belongsTo(Author::class);
}
}
any demo with a working demo of media upload using the latest craftable version with those changes?
Any help appreciated! thanks
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 15 (8 by maintainers)
You probably didn’t follow the instruction from upgrade guide correctly. You have these lines missing:
use Brackets\Media\HasMedia\AutoProcessMediaTrait; use Brackets\Media\HasMedia\ProcessMediaTrait;Than inside model class you have missing:
use AutoProcessMediaTrait; use HasMediaCollectionsTrait; use ProcessMediaTrait;You don’t need to use
use HasMediaTrait;Example of working model:
sorry it is craftable 5 now with Laravel 6 because I updated both and follow up the guidelines too:
https://docs.spatie.be/laravel-medialibrary/v7/converting-images/defining-conversions/
here my post model
here my form-elements.blade.php
and inside media-uploader.blade.php vendor/brackets/admin-ui/resources/views/admin/includes/media-uploader.blade.php I see this code:
my composer:
getThumbs200ForCollection does not exist anyway! but I get this error now:
error:
You have commented out the use Brackets\Media\HasMedia\HasMediaCollectionsTrait;. What is the reason? It is required as in previous versions.