AppServiceProvider.php文件上的运行时错误。遵循我的代码
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema;
use App\Category;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
View::share('name','bitm');
View::composer('frontEnd.includes.menu',function($view){
$publishedCategories = Category::where('publicationStatus',1)->get();
$view->with('publishedCategories',$publishedCategories);
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
任何人都可以帮助我吗?
答案 0 :(得分:1)
您缺少名称空间\Illuminate\Support\Facades\View::share()
或
use \Illuminate\Support\Facades\View;
修改
正如@ d3jn所指出的,正确的方法就是use View;
。