Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
THE PHP FRAMEWORK FOR WEB ARTISANS.С сайта laravel.com.
PHP THAT DOESN'T HURT. CODE HAPPY & ENJOY THE FRESH AIR.
И наверняка будет торрент с этими модулями, который будет регулярно обновляться.
So, what is the solution to this dilemma? Many developers start packing logic into their controllers.
Once the controllers get large enough, they need to re-use business logic that is in other controllers.
Instead of extracting the logic into another class, most developers mistakenly assume they need to
call controllers from within other controllers. This pattern is typically called “HMVC”. Unfortunately,
this pattern often indicates poor application design, and controllers that are much too complicated.
Feel the need to call controllers from other controllers? Extract the logic into a third class that can be injected into any controller.
Taylor Otwell — Laravel: From Apprentice To Artisan, страница 24
class Author extends Eloquent
{
public function posts()
{
return DB::table(self::$table)
->leftJoin('author', 'post.id', '=', 'author.id')
->whereRaw('author.name = ?', [*****])
->get();
}
}class Author extends Eloquent
{
public function posts()
{
return $this->hasMany('Post');
}
}
class Post extends Eloquent
{
public function posts()
{
return $this->belongsTo('Author');
}
}
select * from booksselect * from authors where id in (1, 2, 3, 4, 5, ...)public function postsBy($author)
{
return $this->belongsTo('author')->where('author_name', '=', $author);
}
Laravel. Интернет-ресурсы