I want to share a variable of my views with:
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
\Schema::defaultStringLength(191);
$customers = Customer::get();
\View::share('customers', $customers);
}
}
它可以正常工作,但是当我想通过Artisan迁移我的表时,它会抛出一个错误,没有找到customers
的表,因为在迁移开始之前判断了它.所以我需要一些像这样的东西
if(!artisan_request) {
//request to laravel is via web and not artisan
}
But I haven't found anything in the documentation.