Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call to undefined method stdClass::getMedia() #45

Closed
yabasha opened this issue Dec 28, 2018 · 1 comment
Closed

call to undefined method stdClass::getMedia() #45

yabasha opened this issue Dec 28, 2018 · 1 comment

Comments

@yabasha
Copy link

yabasha commented Dec 28, 2018

Hi,

After installing the library and configured my model to use the media library like illustrated, but when I go to the resource index page I get this error message
call to undefined method stdClass::getMedia()

My model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\Models\Media;

class Offer extends Model
{
    protected $fillable = [
        'title',
        'note',
        'meta',
        'lead_id',
    ];

    protected $casts = [
        'meta' => 'object',
        'win_date' => 'date',
    ];

    public function lead(){
        return $this->belongsTo(Lead::class);
    }

    public function referral(){
        return $this->belongsTo(Referral::class);
    }

    public function registerMediaConversions(Media $media = null)
    {
        $this->addMediaConversion('thumb')
            ->width(130)
            ->height(130);
    }

    public function registerMediaCollections()
    {
        $this->addMediaCollection('main')->singleFile();
        $this->addMediaCollection('my_multi_collection');
    }
}
@ebess
Copy link
Owner

ebess commented Dec 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants