多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
``` public function create() // get method { $targets = Target::orderBy('ranking', 'desc')->orderBy('created_at', 'desc')->paginate(10); return view("create", compact('targets')); } public function store() // post method { $this->validate(request(), [ 'target' => 'required|string|min:1', 'ranking' => 'max:2', ],[ 'target.required' => 'target must be required', 'target.min' => 'target min number word is 1', 'ranking.max' => 'ranking max number is 2', ]); Target::create ([ 'target' => request('target'), 'ranking' => request('ranking'), ]); return redirect("/"); } ``` ``` <form action="/create" method="POST"> {{ csrf_field() }} <button type="submit" class="btn btn-primary right action_submit">Create</button> <div class="clearfix"></div> <div class="form-group"> <label for="usr">Target:</label> <input type="text" class="form-control" id="usr" name="target"> </div> <div class="form-group"> <label for="pwd">Ranking:</label> <input type="number" class="form-control" id="pwd" name="ranking"> </div> </form> </div> ``` ``` @if(count($errors) > 0) <div class="alert alert-danger" role="alert"> @foreach($errors->all() as $error) <li>{{$error}}</li> @endforeach </div> @endif ```