I get class Page not found when I try to retrieve a field from Page. So on $section->sectionable->title
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; class Section extends Model { protected $table = 'sections'; protected $fillable = ['name','description','slug','section_type','status']; protected $hidden = ['id' , 'deleted_at']; public function sectionable() { return $this->morphTo(); } } class Page extends Model { protected $table = 'pages'; protected $fillable = ['title','body','slug','status','meta_title','meta_description','meta_keywords']; public function author() { return $this->belongsTo('App\Models\User', 'user_id'); } public function sections() { return $this->morphMany('App\Models\Section', 'sectionable'); } }I came across the same problem above. Is there any solution or workaround to this one?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community