Sorry for bad English at first ) I'm new to laravel5 and trying to use polymorphic relations
here is the code
class Post extends Model
{
public function seo()
{
return $this->MorphMany('App\Seo' , 'seoable');
}
}
class Seo extends Model
{
public function seoble()
{
return $this->morphTo();
}
}
and in the view I try to retrieve post seo data like this
$post->seo()->title;
here is my DB
Schema::create('seos', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('keywords');
$table->text('description');
$table->string('og_type');
$table->string('og_title');
$table->text('og_description');
$table->integer('seoable_id');
$table->string('seoable_type');
$table->timestamps();
});
but I got the error
Undefined property:
Illuminate\Database\Eloquent\Relations\MorphMany::$title (View: /Applications/MAMP/htdocs/lblog/resources/views/posts/form.blade.php)