| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Uccello\Core\Support\Traits; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Uccello\Core\Models\Entity; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Uccello\Core\Models\Module; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Illuminate\Support\Facades\Cache; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Uccello\Core\Support\Scopes\AssignedUser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Illuminate\Support\Facades\Auth; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | trait UccelloModule | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |      * The "booting" method of the model. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     protected static function boot() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         parent::boot(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         if(static::isFilteredByUser()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |             static::addGlobalScope(new AssignedUser); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     protected static function isFilteredByUser() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $user = Auth::user(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         if($user && !$user->is_admin) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |             $module = static::getModuleFromClass(static::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             if($module && $module->data && property_exists($module->data, 'private') &&  $module->data->private) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |                 return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     public function gettableAttribute() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         return $this->table; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     public function getModuleAttribute() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     {         | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         return static::getModuleFromClass(get_class($this)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     protected static function getModuleFromClass($className) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $modules = Cache::rememberForever('modules_by_model_class', function () { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             $modulesGroupedByModelClass = collect(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             Module::all()->map(function ($item) use ($modulesGroupedByModelClass) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                 $modulesGroupedByModelClass[$item->model_class] = $item; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 return $modulesGroupedByModelClass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             return $modulesGroupedByModelClass; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         return $modules[(string) $className] ?? null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     public function getUidAttribute() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $uid = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $entity = Entity::where('module_id', $this->module->getKey()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                         ->where('record_id', $this->getKey()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                         ->first(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         if($entity) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             $uid = $entity->getKey(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         return $uid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * Returns Assigned User | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * @return string|null | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 88 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 89 |  |  |     public function getAssignedUserAttribute(): ?string | 
            
                                                        
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 91 |  |  |         return $this->assigned_user_id; | 
            
                                                        
            
                                    
            
            
                | 92 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 93 |  |  | } | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths