vendredi 23 décembre 2016

Is it possible One Model has many MorphTo() function?

I have a model call "Post"

class Post extends Model{

public function articleable(){
return $this->morphTo()
}
public function rateable(){
return $this->morphTo()
}

}
the articleable has many type for example "video":
class video extends model{
public function articleable(){
...
return $this->morphMany('App\Post','articleable');

}
the rateable also has many type for example "like":
class like extends model{
....
public function rateable(){
return $this->morphMany('App\Post','rateable');

}
The question is, when I execute the code. there are an error BadMethodCallException with message 'Call to undefined method Illuminate\Database\Query\Builder::acrticleable()'. Is it possible to use in this case?

Kind regards

Javier



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire