Voyager: New BREAD tries to call a non-existing method in my model class

Created on 14 Oct 2018  路  6Comments  路  Source: the-control-group/voyager

Version information

  • Laravel: v5.7
  • Voyager: v1.1
  • PHP: 7.2.10
  • Database: Mysql 8.0.12

Description

I have a post model that include the usual fields like what use it belongs to, text, title, image etc.
And whenever I try to edit a brand new BREAD entry, as in the model entry I get an error like this:
Call to undefined method App\Post::getTranslationsOf()
Which is obviusly not the correct method as I haven't implemented it. The multilingual config is in it's default and other BREAD works fine. It seems to get stuck at a simple "title" text part, trying to call a non existing method.

Steps To Reproduce

  1. Create new BREAD without changing anything in the BREAD settings
  2. Go to the new BREAD section and try to edit an entry.
  3. See error

Additional information

Here is what my model class looks like:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    public function user()
    {
        return $this-> belongsTo('App\User');
    }
}

Here is the migration of said model:

Schema::create('posts', function (Blueprint $table) {
            $table->increments('id');
            $table->text('title');
            $table->longText('text');
            $table->string('header_image');
            $table->string('slug')->unique();
            $table->integer('user_id')->unsigned()->index()->nullable();
            $table->foreign('user_id')->references('id')->on('users');
            $table->timestamps();
        });

Most helpful comment

because posts is custom voyager view under vendor directory.
see: https://github.com/the-control-group/voyager/blob/1.1/resources/views/posts/edit-add.blade.php .
I having tried yet but copying this view https://github.com/the-control-group/voyager/blob/1.1/resources/views/bread/edit-add.blade.php to resources/views/vendor/voyager/posts/edit-add.blade.php may fix this problem.

All 6 comments

I tried the exact same thing, and I got the exact same error.

Same problem here. In my case, I create my table in the Voyager Panel and still not including the relationship in the model, it returns the same error when I try to create a new post. Any solutions for your cases ?

because posts is custom voyager view under vendor directory.
see: https://github.com/the-control-group/voyager/blob/1.1/resources/views/posts/edit-add.blade.php .
I having tried yet but copying this view https://github.com/the-control-group/voyager/blob/1.1/resources/views/bread/edit-add.blade.php to resources/views/vendor/voyager/posts/edit-add.blade.php may fix this problem.

You can just override that view and

@include('voyager::bread.edit-add')

Closing as solutions are provided above.

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TXRRNT picture TXRRNT  路  3Comments

kevinjon27 picture kevinjon27  路  3Comments

winex01 picture winex01  路  3Comments

MikadoInfo picture MikadoInfo  路  3Comments

iwasherefirst2 picture iwasherefirst2  路  3Comments