* Make a form builder. * * @return Form */
()
| 143 | * @return Form |
| 144 | */ |
| 145 | public function form() |
| 146 | { |
| 147 | $showStatus = Link::showStatus(); |
| 148 | $url = request()->header('referer'); |
| 149 | $query = parse_url($url, PHP_URL_QUERY); |
| 150 | parse_str($query, $param); |
| 151 | $localAppId = $param['local_app_id'] ?? 0; |
| 152 | //if (!$localAppId) { |
| 153 | // $localAppId = request()->get('local_app_id'); |
| 154 | //} |
| 155 | $form = new Form(new Project()); |
| 156 | |
| 157 | $userTable = (new Project())->getTable(); |
| 158 | $connection = 'mysql'; |
| 159 | $form->tools(function (Form\Tools $tools) { |
| 160 | // 去掉`列表`按钮 wx10c70673459fdcb3 |
| 161 | $tools->disableList(); |
| 162 | // 去掉`查看`按钮 |
| 163 | $tools->disableView(); |
| 164 | }); |
| 165 | |
| 166 | $form->display('id', 'ID'); |
| 167 | $form->text('app_id', '项目应用ID'); |
| 168 | $form->text('title', '项目标题'); |
| 169 | $form->textarea('description', '项目描述') |
| 170 | ->creationRules([ "unique:{$connection}.{$userTable}"]); |
| 171 | //->updateRules([ "unique:{$connection}.{$userTable},description,{{id}}"]); |
| 172 | $form->image('image', '项目缩略图'); |
| 173 | $form->select('status', '是否展示')->options($showStatus)->default(1); |
| 174 | $form->number('sort', '排序')->required('integer'); |
| 175 | //$form->number('h5_sort', 'h5链接排序')->required('integer'); |
| 176 | |
| 177 | $form->text('path', '项目应用跳转路径'); |
| 178 | //$form->text('url', 'H5跳转链接'); |
| 179 | |
| 180 | $form->datetime('created_at', '创建时间'); |
| 181 | //$form->text('specs', '规格')->rules('required'); |
| 182 | |
| 183 | $form->saving(function (Form $form) { |
| 184 | //$form->image_url; |
| 185 | //$form->model()->created_date = date("Y-m-d", strtotime($form->created_at)); |
| 186 | }); |
| 187 | return $form; |
| 188 | } |
| 189 | } |
nothing calls this directly
no test coverage detected