代码之家  ›  专栏  ›  技术社区  ›  Vpa

无法在仪表板中显示Laravel Voyager小部件

  •  0
  • Vpa  · 技术社区  · 6 年前

    我试图在我的仪表板上显示小部件,但它不能显示任何小部件。

    我关注这个视频 Voyager Academy Video 15 - Custom Dashboard Widgets

    我做了他在这段视频中所做的一切,但不能在我的仪表板上显示任何东西。

    配置->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()函数内部,它只是复制粘贴。

    1 回复  |  直到 6 年前
        1
  •  0
  •   Thalles Freitas    6 年前

    是高速缓存。 只需执行-php artisan config:cache