{"id":561,"date":"2021-07-04T05:39:26","date_gmt":"2021-07-04T05:39:26","guid":{"rendered":"http:\/\/robinluo.top\/?p=561"},"modified":"2021-07-04T05:39:26","modified_gmt":"2021-07-04T05:39:26","slug":"laravel-form-magic-%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/robinluo.top\/?p=561","title":{"rendered":"laravel Form magic \u65b9\u6cd5"},"content":{"rendered":"\n<p>laravel \u7684form \u5bf9\u8c61 \u6709magic\u65b9\u6cd5 \u53ef\u4ee5\u5feb\u901f\u6dfb\u52a0\u8868\u5355\u9879<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\r\n * Class Form.\r\n *\r\n * @method Field\\Text           text($name, $label = '')\r\n * @method Field\\Password       password($name, $label = '')\r\n * @method Field\\Checkbox       checkbox($name, $label = '')\r\n * @method Field\\CheckboxButton checkboxButton($name, $label = '')\r\n * @method Field\\CheckboxCard   checkboxCard($name, $label = '')\r\n * @method Field\\Radio          radio($name, $label = '')\r\n * @method Field\\RadioButton    radioButton($name, $label = '')\r\n * @method Field\\RadioCard      radioCard($name, $label = '')\r\n * @method Field\\Select         select($name, $label = '')\r\n * @method Field\\MultipleSelect multipleSelect($name, $label = '')\r\n * @method Field\\Textarea       textarea($name, $label = '')\r\n * @method Field\\Hidden         hidden($name, $label = '')\r\n * @method Field\\Id             id($name, $label = '')\r\n * @method Field\\Ip             ip($name, $label = '')\r\n * @method Field\\Url            url($name, $label = '')\r\n * @method Field\\Color          color($name, $label = '')\r\n * @method Field\\Email          email($name, $label = '')\r\n * @method Field\\Mobile         mobile($name, $label = '')\r\n * @method Field\\Slider         slider($name, $label = '')\r\n * @method Field\\File           file($name, $label = '')\r\n * @method Field\\Image          image($name, $label = '')\r\n * @method Field\\Date           date($name, $label = '')\r\n * @method Field\\Datetime       datetime($name, $label = '')\r\n * @method Field\\Time           time($name, $label = '')\r\n * @method Field\\Year           year($column, $label = '')\r\n * @method Field\\Month          month($column, $label = '')\r\n * @method Field\\DateRange      dateRange($start, $end, $label = '')\r\n * @method Field\\DateTimeRange  dateTimeRange($start, $end, $label = '')\r\n * @method Field\\TimeRange      timeRange($start, $end, $label = '')\r\n * @method Field\\Number         number($name, $label = '')\r\n * @method Field\\Currency       currency($name, $label = '')\r\n * @method Field\\SwitchField    switch($name, $label = '')\r\n * @method Field\\Display        display($name, $label = '')\r\n * @method Field\\Rate           rate($name, $label = '')\r\n * @method Field\\Divider        divider($title = '')\r\n * @method Field\\Decimal        decimal($column, $label = '')\r\n * @method Field\\Html           html($html)\r\n * @method Field\\Tags           tags($column, $label = '')\r\n * @method Field\\Icon           icon($column, $label = '')\r\n * @method Field\\Captcha        captcha($column, $label = '')\r\n * @method Field\\Listbox        listbox($column, $label = '')\r\n * @method Field\\Table          table($column, $label, $builder)\r\n * @method Field\\Timezone       timezone($column, $label = '')\r\n * @method Field\\KeyValue       keyValue($column, $label = '')\r\n * @method Field\\ListField      list($column, $label = '')\r\n * @method mixed                handle(Request $request)\r\n *\/<\/code><\/pre>\n\n\n\n<p>\u771f\u5b9e\u8c03\u7528\u7684\u65b9\u6cd5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> \/**\r\n     * Generate a Field object and add to form builder if Field exists.\r\n     *\r\n     * @param string $method\r\n     * @param array  $arguments\r\n     *\r\n     * @return Field|$this\r\n     *\/\r\n    public function __call($method, $arguments)\r\n    {\r\n        if (!$this->hasField($method)) {\r\n            return $this;\r\n        }\r\n\r\n        $class = BaseForm::$availableFields&#91;$method];\r\n\r\n        $field = new $class(Arr::get($arguments, 0), array_slice($arguments, 1));\r\n\r\n        return tap($field, function ($field) {\r\n            $this->pushField($field);\r\n        });\r\n    }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>laravel \u7684form \u5bf9\u8c61 \u6709magic\u65b9\u6cd5 \u53ef\u4ee5\u5feb\u901f\u6dfb\u52a0\u8868\u5355\u9879 \u771f\u5b9e\u8c03\u7528\u7684\u65b9\u6cd5<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[10,51],"_links":{"self":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/561"}],"collection":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=561"}],"version-history":[{"count":1,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/561\/revisions"}],"predecessor-version":[{"id":562,"href":"https:\/\/robinluo.top\/index.php?rest_route=\/wp\/v2\/posts\/561\/revisions\/562"}],"wp:attachment":[{"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robinluo.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}