22
33namespace QCod \AppSettings \Setting ;
44
5+ use Illuminate \Support \Arr ;
6+ use Illuminate \Support \Str ;
57use Illuminate \Http \Request ;
68use Illuminate \Support \Facades \Storage ;
79use QCod \Settings \Setting \SettingStorage ;
@@ -55,14 +57,14 @@ public function get($name, $default = null)
5557 // get the setting and fallback to default value from config
5658 $ value = $ this ->settingStorage ->get (
5759 $ name ,
58- array_get ($ settingField , 'value ' , $ default )
60+ Arr:: get ($ settingField , 'value ' , $ default )
5961 );
6062
6163 // cast the value
62- $ outValue = $ this ->castValue (array_get ($ settingField , 'data_type ' ), $ value , true );
64+ $ outValue = $ this ->castValue (Arr:: get ($ settingField , 'data_type ' ), $ value , true );
6365
6466 // check for accessor to run
65- if ($ accessor = array_get ($ settingField , 'accessor ' )) {
67+ if ($ accessor = Arr:: get ($ settingField , 'accessor ' )) {
6668 $ outValue = $ this ->runCallback ($ accessor , $ name , $ value );
6769 }
6870
@@ -79,12 +81,12 @@ public function get($name, $default = null)
7981 public function set ($ name , $ value )
8082 {
8183 $ settingField = $ this ->getSettingField ($ name );
82- $ dataType = array_get ($ settingField , 'data_type ' );
84+ $ dataType = Arr:: get ($ settingField , 'data_type ' );
8385
8486 $ val = $ this ->castValue ($ dataType , $ value );
8587
8688 // check for mutator to run
87- if ($ mutator = array_get ($ settingField , 'mutator ' )) {
89+ if ($ mutator = Arr:: get ($ settingField , 'mutator ' )) {
8890 $ val = $ this ->runCallback ($ mutator , $ name , $ value );
8991 }
9092
@@ -142,7 +144,7 @@ public function loadConfig($config)
142144 array_walk_recursive ($ config , function (&$ value , $ key ) {
143145 if (!in_array ($ key , ['mutator ' , 'accessor ' , 'rules ' ]) && is_callable ($ value )) {
144146 // skip any string which dont look like namesapce
145- if (is_string ($ value ) && str_contains ($ value , '\\' ) == false ) {
147+ if (is_string ($ value ) && Str:: contains ($ value , '\\' ) == false ) {
146148 return ;
147149 }
148150
@@ -171,7 +173,7 @@ protected function getSettingUISections()
171173 public function getAllSettingFields ()
172174 {
173175 return $ this ->getSettingUISections ()->flatMap (function ($ field ) {
174- return array_get ($ field , 'inputs ' , []);
176+ return Arr:: get ($ field , 'inputs ' , []);
175177 });
176178 }
177179
@@ -185,7 +187,7 @@ public function getSettingField($name)
185187 {
186188 return $ this ->getAllSettingFields ()
187189 ->first (function ($ field ) use ($ name ) {
188- return array_get ($ field , 'name ' ) == $ name ;
190+ return Arr:: get ($ field , 'name ' ) == $ name ;
189191 }, []);
190192 }
191193
@@ -301,11 +303,11 @@ private function castToArray($value, $out)
301303 */
302304 private function uploadFile ($ setting , $ request )
303305 {
304- $ settingName = array_get ($ setting , 'name ' );
306+ $ settingName = Arr:: get ($ setting , 'name ' );
305307
306308 // get the disk and path to upload
307- $ disk = array_get ($ setting , 'disk ' , 'public ' );
308- $ path = array_get ($ setting , 'path ' , '/ ' );
309+ $ disk = Arr:: get ($ setting , 'disk ' , 'public ' );
310+ $ path = Arr:: get ($ setting , 'path ' , '/ ' );
309311
310312 $ uploadedPath = null ;
311313 $ oldFile = $ this ->get ($ settingName );
0 commit comments