在Laravel 3中,可以在模型中执行以下操作(http://laravel.com/docs/database/eloquent#eager):
class Book extends Eloquent
{
public $includes = array('author'); // this line
public function author()
{
return $this->belongs_to('Author');
}
}
Run Code Online (Sandbox Code Playgroud)
如果经常加载相同的模型,这是有用的.
在Laravel 4中,添加"此行"似乎并没有引起急切的加载.它似乎也没有在文档中提及(http://four.laravel.com/docs/eloquent#eager-loading).
它被其他东西取代了还是这个功能简直消失了?
更新:
我看过模型的来源(很高兴阅读).下雪了:
/**
* The relations to eager load on every query.
*
* @var array
*/
protected $with = array();
Run Code Online (Sandbox Code Playgroud)
是否有任何方法可以建议将其添加(返回)到文档中(这似乎是一件容易被忽视的小事情)?
当我运行composer update时,我收到以下错误:
使用包信息加载composer存储库更新依赖项(包括require-dev)无需安装或更新生成自动加载文件Illuminate\Foundation\ComposerScripts :: postUpdate php artisan optimize [Symfony\Component\Debug\Exception\FatalErrorException] Class'Laravel\Cashier\CashierServiceProvider'未找到脚本php artisan优化处理使用err或代码255返回的post-update-cmd事件
我将此代码放在app.php文件中
Laravel \出纳\ CashierServiceProvider ::类,
而在composer.json我也把它
"laravel/cashier":"~6.0"
就像在laravel doc中一样