Ok im building my First widget,
But i just added it to the Dashboard??
Has anyone had the same problem and solved it?
         
        
           
         
            
       
      
        
          
          
            apinard  
          
              
                September 11, 2024,  1:23pm
               
              #2 
           
         
        
          Hi @codeskullz  ,
It did happen to me but I don’t recall why and how I solved it. I have in mind the $defaultAlias variable.
You have it set?
         
        
           
         
            
       
      
        
        
          Hi @apinard , Thank you for your reply to my message
Yes, I also see in the database that this is added. I have checked the code 3 times but either I am missing something or I just don’t know.
         
        
           
         
            
       
      
        
          
          
            apinard  
          
              
                September 11, 2024,  2:24pm
               
              #4 
           
         
        
          @codeskullz  , remove the validation part and see if it works:
'validation' => [
                    'required' => [
                        'message' => 'The Name field is required'
                    ],
                    'regex' => [
                        'message' => 'The Name field can contain only Latin letters.',
                        'pattern' => '^[a-zA-Z]+$'
                    ]
                ]
I think it was the reason. Because it doesn’t respect the regex if you don’t enter anything
         
        
           
         
            
       
      
        
        
          Unfortunately that didn’t work. I’ll look at it again later. Thanks in advance
         
        
           
         
            
       
      
        
          
          
            snipi  
          
              
                September 12, 2024,  7:39am
               
              #6 
           
         
        
          
looks strange, because i copied your code (removed some models based things to work without any data) and it shows correctly.
can you paste a _widget partial code too?
         
        
           
         
            
       
      
        
        
          
i used to create a new widget.
php artisan create:reportwidget nielsvandendries.therantzone TestWidget
I didnt change any code only added it to the Plugin.php to regsiter.
    public function registerReportWidgets()
    {
        return [
            'NielsVanDenDries\Therantzone\ReportWidgets\TotalRants' => [
                'label'   => 'Total Rants',
                'context' => 'dashboard',
                'permissions' => ['nielsvandendries.therantzone.therantzone_manager']
            ],
            'NielsVanDenDries\Therantzone\ReportWidgets\TestWidget' => [
                'label'   => 'Test Widget',
                'context' => 'dashboard',
                'permissions' => ['nielsvandendries.therantzone.therantzone_manager']
            ],
        ];
    }
I can even see it is added to the database table “backend_user_preferences”.
I even pushed it to my production environment, (thats a diffrent OCT installation) but still the same.
         
        
           
         
            
       
      
        
          
          
            apinard  
          
              
                September 13, 2024, 10:27pm
               
              #8 
           
         
        
          @codeskullz  I think it might be the namespace.
you have in Plugin.php:
NielsVanDenDries\Therantzone\ReportWidgets\TotalRants
and you namespace that is set in your reportwidget is:
Nielsvandendries\Therantzone\ReportWidgets;
Try:
  public function registerReportWidgets()
    {
        return [
            'Nielsvandendries\Therantzone\ReportWidgets\TotalRants' => [
                'label'   => 'Total Rants',
                'context' => 'dashboard',
                'permissions' => ['nielsvandendries.therantzone.therantzone_manager']
            ],
        ];
    }
If not, adding debug points and stepping through the files should help pinpoint where the issue lies.
         
        
           1 Like 
         
         
            
       
      
        
        
          @apinard  omg that did the job, how did i not see that.@apinard  and @snipi 
         
        
           1 Like