44
55use Laravel \Nova \Fields \Field ;
66use Laravel \Nova \Resource ;
7+ use Illuminate \Support \Arr ;
8+ use Illuminate \Support \Str ;
79
810class Button extends Field
911{
@@ -55,7 +57,7 @@ public function __construct($name, $key = null)
5557 {
5658 $ this ->name = $ name ;
5759 $ this ->text = $ name ;
58- $ this ->key = $ key ?? kebab_case ($ name );
60+ $ this ->key = $ key ?? Str:: kebab ($ name );
5961 $ this ->config = config ('nova-button ' );
6062 $ this ->addDefaultSettings ();
6163 }
@@ -65,10 +67,10 @@ public function resolve($resource, $attribute = null)
6567 parent ::resolve ($ resource , $ attribute );
6668
6769 $ this ->classes [] = 'nova-button- ' .strtolower (class_basename ($ resource ));
68- $ this ->classes [] = array_get ($ this ->config , "styles. {$ this ->style }" );
69- $ this ->loadingClasses = array_get ($ this ->config , "styles. {$ this ->loadingStyle }" );
70- $ this ->successClasses = array_get ($ this ->config , "styles. {$ this ->successStyle }" );
71- $ this ->errorClasses = array_get ($ this ->config , "styles. {$ this ->errorStyle }" );
70+ $ this ->classes [] = Arr:: get ($ this ->config , "styles. {$ this ->style }" );
71+ $ this ->loadingClasses = Arr:: get ($ this ->config , "styles. {$ this ->loadingStyle }" );
72+ $ this ->successClasses = Arr:: get ($ this ->config , "styles. {$ this ->successStyle }" );
73+ $ this ->errorClasses = Arr:: get ($ this ->config , "styles. {$ this ->errorStyle }" );
7274
7375 $ this ->withMeta ([
7476 'key ' => $ this ->key ,
@@ -320,30 +322,30 @@ protected function normalizeResourceName($namespace)
320322 public function addDefaultSettings ()
321323 {
322324 $ this ->addLinkFallbacks ();
323- $ this ->style = array_get ($ this ->config , 'defaults.style ' , 'link-primary ' );
324- $ this ->loadingText = array_get ($ this ->config , 'defaults.loadingText ' , 'Loading ' );
325- $ this ->loadingStyle = array_get ($ this ->config , 'defaults.loadingStyle ' , str_replace ('primary ' , 'grey ' , $ this ->style ));
326- $ this ->errorText = array_get ($ this ->config , 'defaults.errorText ' , 'Error! ' );
327- $ this ->errorStyle = array_get ($ this ->config , 'defaults.errorStyle ' , str_replace ('primary ' , 'danger ' , $ this ->style ));
328- $ this ->successText = array_get ($ this ->config , 'defaults.successText ' , 'Success! ' );
329- $ this ->successStyle = array_get ($ this ->config , 'defaults.successStyle ' , str_replace ('primary ' , 'success ' , $ this ->style ));
325+ $ this ->style = Arr:: get ($ this ->config , 'defaults.style ' , 'link-primary ' );
326+ $ this ->loadingText = Arr:: get ($ this ->config , 'defaults.loadingText ' , 'Loading ' );
327+ $ this ->loadingStyle = Arr:: get ($ this ->config , 'defaults.loadingStyle ' , str_replace ('primary ' , 'grey ' , $ this ->style ));
328+ $ this ->errorText = Arr:: get ($ this ->config , 'defaults.errorText ' , 'Error! ' );
329+ $ this ->errorStyle = Arr:: get ($ this ->config , 'defaults.errorStyle ' , str_replace ('primary ' , 'danger ' , $ this ->style ));
330+ $ this ->successText = Arr:: get ($ this ->config , 'defaults.successText ' , 'Success! ' );
331+ $ this ->successStyle = Arr:: get ($ this ->config , 'defaults.successStyle ' , str_replace ('primary ' , 'success ' , $ this ->style ));
330332 }
331333
332334 public function addLinkFallbacks ()
333335 {
334- if (!array_has ($ this ->config , 'styles.link-primary ' )) {
336+ if (!Arr:: has ($ this ->config , 'styles.link-primary ' )) {
335337 $ this ->config ['styles ' ]['link-primary ' ] = 'cursor-pointer dim inline-block text-primary font-bold no-underline ' ;
336338 }
337339
338- if (!array_has ($ this ->config , 'styles.link-success ' )) {
340+ if (!Arr:: has ($ this ->config , 'styles.link-success ' )) {
339341 $ this ->config ['styles ' ]['link-success ' ] = 'cursor-pointer dim inline-block text-success font-bold no-underline ' ;
340342 }
341343
342- if (!array_has ($ this ->config , 'styles.link-grey ' )) {
344+ if (!Arr:: has ($ this ->config , 'styles.link-grey ' )) {
343345 $ this ->config ['styles ' ]['link-grey ' ] = 'cursor-pointer dim inline-block text-grey font-bold no-underline ' ;
344346 }
345347
346- if (!array_has ($ this ->config , 'styles.link-danger ' )) {
348+ if (!Arr:: has ($ this ->config , 'styles.link-danger ' )) {
347349 $ this ->config ['styles ' ]['link-danger ' ] = 'cursor-pointer dim inline-block text-danger font-bold no-underline ' ;
348350 }
349351 }
0 commit comments