R
R
root092018-07-03 12:15:41
Laravel
root09, 2018-07-03 12:15:41

What type of relationship should be used in this case?

There is a model " Articles " with articles, there is a task to display related articles (for example, an article with id 1 is associated with articles with id 2 and 3), what type of relationship should be used?
That is, the type of table should be something like this, as I understand it:
id, article_id, related_id

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
netrox, 2018-07-03
@root09

return $this->belongsToMany(
    		Article::class,
    		'article_related',
    		'article_id',
    		'related_id'
    	);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question