1616 * @method static string danger($text, $url, $confirm = null, $disabled = false)
1717 * @method static string success($text, $url, $confirm = null, $disabled = false)
1818 *
19- * @method void text($text)
20- * @method void type($type)
21- * @method void confirm($text)
22- * @method void url($url)
23- * @method void disabled($boolean)
19+ * @method $this text($text)
20+ * @method $this type($type)
21+ * @method $this confirm($text)
22+ * @method $this url($url)
23+ * @method $this disabled($boolean)
24+ * @method $this attr($attr)
2425 */
2526class TextAjaxRequest extends AbstractWidget
2627{
@@ -31,6 +32,19 @@ public static function getAssets()
3132 ];
3233 }
3334
35+ /**
36+ * @param ...$arguments string type,text,url
37+ * @return $this
38+ */
39+ public static function make (...$ arguments )
40+ {
41+ $ ins = new static ();
42+ $ ins ->type ($ arguments [0 ]);
43+ $ ins ->text ($ arguments [1 ]);
44+ $ ins ->url ($ arguments [2 ]);
45+ return $ ins ;
46+ }
47+
3448 public static function __callStatic ($ name , $ arguments )
3549 {
3650 $ methods = ['primary ' , 'muted ' , 'warning ' , 'danger ' , 'success ' ,];
@@ -51,7 +65,12 @@ public function render()
5165 if ($ this ->disabled ) {
5266 return '<a href="javascript:;" class="ub-text-ajax-request ub-text- ' . $ this ->type . '"> ' . $ this ->text . '</a> ' ;
5367 } else {
54- return '<a href="javascript:;" ' . ($ this ->confirm ? 'data-confirm=" ' . $ this ->confirm . '" ' : '' ) . ' data-ajax-request-loading data-ajax-request=" ' . $ this ->url . '" class="ub-text-ajax-request ub-text- ' . $ this ->type . '"> ' . $ this ->text . '</a> ' ;
68+ return '<a href="javascript:;" ' . ($ this ->confirm ? 'data-confirm=" ' . $ this ->confirm . '" ' : '' )
69+ . ' data-ajax-request-loading data-ajax-request=" ' . $ this ->url
70+ . '" class="ub-text-ajax-request ub-text- ' . $ this ->type . '" '
71+ . ' ' . ($ this ->attr ? $ this ->attr : '' )
72+ . '> '
73+ . $ this ->text . '</a> ' ;
5574 }
5675 }
57- }
76+ }
0 commit comments