* Make a form builder. * * @return Form */
()
| 134 | * @return Form |
| 135 | */ |
| 136 | public function form() |
| 137 | { |
| 138 | $showStatus = Link::showStatus(); |
| 139 | $url = request()->header('referer'); |
| 140 | $query = parse_url($url, PHP_URL_QUERY); |
| 141 | parse_str($query, $param); |
| 142 | $form = new Form(new Link()); |
| 143 | |
| 144 | $userTable = (new Link())->getTable(); |
| 145 | $connection = 'mysql'; |
| 146 | $form->tools(function (Form\Tools $tools) { |
| 147 | // 去掉`列表`按钮 |
| 148 | $tools->disableList(); |
| 149 | // 去掉`查看`按钮 |
| 150 | $tools->disableView(); |
| 151 | }); |
| 152 | |
| 153 | $form->display('id', 'ID'); |
| 154 | $form->text('app_id', '友链应用ID'); |
| 155 | $form->text('app_name', '友链应用名称'); |
| 156 | $form->textarea('description', '友链应用') |
| 157 | ->creationRules(['required', "unique:{$connection}.{$userTable}"]) |
| 158 | ->updateRules(['required', "unique:{$connection}.{$userTable},description,{{id}}"]); |
| 159 | $form->image('logo', '友链应用LOGO'); |
| 160 | $form->select('status', '是否展示')->options($showStatus)->default(1); |
| 161 | $form->number('sort', '排序')->required('integer'); |
| 162 | $form->text('path', '友链应用路径'); |
| 163 | $form->datetime('created_at', '创建时间'); |
| 164 | $form->datetime('updated_at', '更新时间'); |
| 165 | //$form->text('specs', '规格')->rules('required'); |
| 166 | |
| 167 | $form->saving(function (Form $form) { |
| 168 | //$form->image_url; |
| 169 | //$form->model()->created_date = date("Y-m-d", strtotime($form->created_at)); |
| 170 | }); |
| 171 | return $form; |
| 172 | } |
| 173 | } |
nothing calls this directly
no test coverage detected