thinkphp5项目--企业单车网站(七)
项目地址
fry404006308/BicycleEnterpriseWebsite: Bicycle Enterprise Website
https://github.com/fry404006308/BicycleEnterpriseWebsite
一、css样式:float和margin-right
<div class="radio " style="float:left;margin-right:10px;">
二、验证器
声明
1 <?php 2 namespace appadminvalidate; 3 4 use thinkValidate; 5 class Admin extends Validate 6 { 7 protected $rule = [ 8 'username' => 'require|max:25|unique:admin', 9 'password' => 'require|min:32', 10 ]; 11 12 protected $message = [ 13 'username.require' => '管理员名称必须填写', 14 'username.max' => '管理员名称最多不能超过25个字符', 15 'password.require' => '管理员密码必须填写', 16 'password.min' => '管理员密码最少32个字符', 17 ]; 18 19 20 protected $scene = [ 21 'add' => ['username'=>'require|unique:admin','password'], 22 'edit' => ['username'=>'require|unique:admin'], 23 ]; 24 }
使用
1 <?php 2 namespace appadmincontroller; 3 use thinkController; 4 use appadminmodelAdmin as ModelAdmin; 5 use thinkValidate; 6 use thinkLoader; 7 use appadmincontrollerBase; 8 9 class Admin extends Base 10 { 11 //增加页 12 public function add() 13 { 14 if(request()->isPost()){ 15 //获取post提交的数据 16 $data=input('post.'); 17 18 //验证 19 $validate = Loader::validate('Admin'); 20 if(!$validate->scene('add')->check($data)){ 21 $this->error($validate->getError()); die; 22 } 23 24 //模型处理获取的数据 25 $modelAdmin= new ModelAdmin(); 26 //结果 27 $res=$modelAdmin->addAdmin($data); 28 29 // $res=db('admin')->insert($data); 30 if($res){ 31 $this->success('添加管理员成功!!',url('admin/lst')); 32 }else{ 33 $this->error('添加管理员失败!!'); 34 } 35 return; 36 } 37 return view(); 38 } 39 40 }
三、css样式:text-align,width
<td align="center"><input type="text" value="{$vo.sort}" style="50px;text-align:center"></td>