Why Custom Dashboard widgets not show What the wrong here?

Posted In Voyager
  • tag-dev 10 months ago
    **Hello First Thanks for reading and helping **
    I created custom widget like a video but not show in dashboard  also no show any error 
    1.  i installed voyager without dummy data by the way .
    2.  any one can help 
    3.  My code there 
    
    ><?php
    
    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

    **Hello First Thanks for reading and helping ** I created custom widget like a video but not show in dashboard also no show any error

    1. i installed voyager without dummy data by the way .
    2. any one can help
    3. 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

  • devdojo 10 months ago
    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!

    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!

  • tag-dev 10 months ago
    Also dosent Work  No widgets No Errors too | i apperciate your effort for helping me .....  
    **NOTE**
    
    i INSTALLED VOYAGER BY  WITH OUT DUMMY DATA  IS THERE A PROBLEM IN THIS PARTICULAR POINT ?

    Also dosent Work No widgets No Errors too | i apperciate your effort for helping me .....
    NOTE

    i INSTALLED VOYAGER BY WITH OUT DUMMY DATA IS THERE A PROBLEM IN THIS PARTICULAR POINT ?

Please login or signup to leave a response.

Login

or Sign Up

Sign Up

or Login
×
tnylea
Cheers Friend!

I'm Tony, the creator of this site. I'm trying to increase my twitter following. Want to follow me?

Follow @tnylea If not, no worries :)