Answer the question
In order to leave comments, you need to log in
How to use models?
While learning Laravel, and MVC in general, I'm making a blog site that has a footprint. tables:
return DB::select(
'SELECT a.`id`, a.`Title`, a.`Text`, a.`create_at`,
(SELECT GROUP_CONCAT(\'<a href="/tag/\', t.id, \'">\', t.`name`, \'</a>\' SEPARATOR \'\')
FROM article_tags _t
INNER JOIN tags t ON _t.tag_id = t.id WHERE _t.article_id = a.id) AS `tags`
FROM articles AS a
LIMIT '.($curPage-1)*$articlesOnPage.', '.$articlesOnPage);
Answer the question
In order to leave comments, you need to log in
1) Article, Tag, Comment models.
For the Article model, links with tags and comments, read about links here
. For article_tags, the model is not needed, and it’s better to call article_tag, it’s more correct, in the laravel style, for example, more details here
2) Not necessarily, but this is the framework’s goodies. Models make simple requests much faster, more elegant than manually.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question