| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace JeroenNoten\LaravelAdminLte\View\Components\Form; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | class SelectBs extends InputGroupComponent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |     use Traits\OldValueSupportTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |      * The bootstrap-select plugin configuration parameters. Array with | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |      * 'key => value' pairs, where the key should be an existing configuration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |      * property of the bootstrap-select plugin. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     public $config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      * Create a new component instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * Note this component requires the 'bootstrap-select' plugin. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 3 |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $name, $id = null, $label = null, $igroupSize = null, $labelClass = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $fgroupClass = null, $igroupClass = null, $disableFeedback = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $errorKey = null, $config = [], $enableOldSupport = null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 3 |  |         parent::__construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 3 |  |             $name, $id, $label, $igroupSize, $labelClass, $fgroupClass, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 3 |  |             $igroupClass, $disableFeedback, $errorKey | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 | 3 |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 3 |  |         $this->config = is_array($config) ? $config : []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 3 |  |         $this->enableOldSupport = isset($enableOldSupport); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * Make the class attribute for the input group item. Note we overwrite | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * the method of the parent class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @return string | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 44 | 1 |  |     public function makeItemClass() | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 46 | 1 |  |         $classes = ['form-control']; | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 48 | 1 |  |         if ($this->isInvalid()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 49 | 1 |  |             $classes[] = 'is-invalid'; | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |         // The next workaround setups the plugin when using sm/lg sizes. | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |         // Note: this may change with newer plugin versions. | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 55 | 1 |  |         if (isset($this->size) && in_array($this->size, ['sm', 'lg'])) { | 
            
                                                                        
                            
            
                                    
            
            
                | 56 | 1 |  |             $classes[] = "form-control-{$this->size}"; | 
            
                                                                        
                            
            
                                    
            
            
                | 57 | 1 |  |             $classes[] = 'p-0'; | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 60 | 1 |  |         return implode(' ', $classes); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * Get the view / contents that represent the component. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * @return \Illuminate\View\View|string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 | 1 |  |     public function render() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 | 1 |  |         return view('adminlte::components.form.select-bs'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 72 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 73 |  |  |  |