Why Custom Dashboard widgets not show What the wrong here?
**Hello First Thanks for reading and helping ** I created custom widget like a video but not show in dashboard also no show any error
- i installed voyager without dummy data by the way .
- any one can help
- My code there
namespace App\Widgets;
use Illuminate\Support\Str; use TCG\Voyager\Facades\Voyager; use TCG\Voyager\Widgets\BaseDimmer; use Illuminate\Support\Facades\Auth; use App\Feature;
class FeaturesWidget extends BaseDimmer { /** * The configuration array. * * @var array */ protected $config = [];
/** * Treat this method as a controller action. * Return view() or other content to display. */ public function run() { $count = Feature::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'), ])); } /** * Determine if the widget should be displayed. * * @return bool */ public function shouldBeDisplayed() { return Auth::user()->can('browse', Voyager::model('Post')); }
}
// voyager.php
'widgets' => [ 'App\Widgets\FeaturesWidget', ],
============================= No showen and not show any errors Thanks So Much for help
Not sure if it will help, but here is a sample custom widget I created in our Ninja Media Script project:
File stored at app\Widgets\CommentDimmer.php
namespace App\Widgets;
use Arrilot\Widgets\AbstractWidget;
use Illuminate\Support\Str;
use TCG\Voyager\Facades\Voyager;
class CommentDimmer extends AbstractWidget
{
/**
* The configuration array.
*
* @var array
*/
protected $config = [];
/**
* Treat this method as a controller action.
* Return view() or other content to display.
*/
public function run()
{
$count = \App\Models\Comment::count();
$string = 'Comments';
return view('voyager::dimmer', array_merge($this->config, [
'icon' => 'voyager-news',
'title' => "{$count} {$string}",
'text' => "You have $count comments in your database. Click on button below to view all comments.",
'button' => [
'text' => 'View All Comments',
'link' => '/admin/comments',
],
'image' => Voyager::image('widgets/comments.png'),
]));
}
}
Here is my widgets array inside my config/voyager.php
'widgets' => [
'App\\Widgets\\PostDimmer',
'App\\Widgets\\CommentDimmer',
'App\\Widgets\\UserDimmer',
],
If you have a sample URL you can share with me, it might be easier to help out with the issue :)
Thanks!