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.
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();
});
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.
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.