[英]Cannot display Laravel Voyager Widgets in Dashboard
我試圖在我的儀表板中顯示小部件,但它無法顯示任何小部件。
我關注此視頻航海者學院視頻 15 - 自定義儀表板小部件
我做了他在這個視頻中所做的一切,但無法在我的儀表板中顯示任何內容。
配置->voyager.php
'widgets' => [
'App\\Widgets\\News',
],
我在應用程序中創建了一個新文件夾Widgets
應用程序->小部件->News.php
<?php
namespace App\Widgets;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use TCG\Voyager\Facades\Voyager;
use Arrilot\Widgets\AbstractWidget;
class News extends AbstractWidget
{
protected $config = [];
public function run()
{
$count = Voyager::model('Post')->count();
$string = trans_choice('voyager::dimmer.post', $count);
return view('voyager::dimmer', array_merge($this->config, [
'icon' => 'voyager-news',
'title' => "{$count} {$string}",
'text' => __('voyager::dimmer.post_text', ['count' => $count, 'string' => Str::lower($string)]),
'button' => [
'text' => __('voyager::dimmer.post_link_text'),
'link' => route('voyager.posts.index'),
],
'image' => voyager_asset('images/widget-backgrounds/02.jpg'),
]));
}
public function shouldBeDisplayed()
{
return Auth::user()->can('browse', Voyager::model('Post'));
}
}
忽略 run() 函數內部,它只是復制粘貼。
是緩存。 只需執行 - php artisan config:cache
這就是問題 :
public function shouldBeDisplayed()
{
return Auth::user()->can('browse', Voyager::model('Post'));
}
如此處所述: https : //stackoverflow.com/a/54451571/11387981發布到相同的內容:更改返回函數。
如果您遇到同樣的問題並且在修改config/voyager.php
文件后沒有看到任何變化,請嘗試執行
php artisan config:clear
首先,您必須對以下內容進行一些更改:
然后,運行 php artisan config:cache
它會起作用,祝你好運
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.