```
public function edit(Target $target)
// get method
{
$targets = Target::orderBy('ranking', 'desc')->orderBy('created_at', 'desc')->paginate(10);
return view("edit", compact('targets', 'target'));
}
public function update(Target $target)
// 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::where('id', $target->id)->update
([
'target' => request('target'),
'ranking' => request('ranking'),
]);
return redirect("/");
}
```
```
<form action="/edit/{{$target->id}}" method="POST">
{{method_field("PUT")}}
{{csrf_field()}}
<button type="submit" class="btn btn-primary right action_submit">update</button>
<div class="clearfix"></div>
<div class="form-group">
<label for="usr">Target:</label>
<input type="text" class="form-control" id="usr" name="target" value="{{$target->target}}">
</div>
<div class="form-group">
<label for="pwd">Ranking:</label>
<input type="number" class="form-control" id="pwd" name="ranking" value="{{$target->ranking}}">
</div>
</form>
```
- PHP Laravel for beginners: from zero fly to the heaven !
- 1.Getting started with laravel: To do list project
- 1.Course overview
- 2.Install xampp and editor
- 3. Download and run laravel
- 4. MVC concept
- 5.Website structure and blade template engine
- 6.CRUD concept: create, read, update, and delete
- 7.Create data by Tinker
- 8.Create data by Factories
- 9.Read function
- 10.Create function
- 11.Update function
- 12.Delete function
- 13.Course summary
- Laravel common command line
- Laravel package and function
- Account 1: Laravel default auth function
- Account 2: Laravel register, login, logout
- Payment : Laravel PayPal
- Payment 2: Laravel alipay
- Payment 3: Laravel wechatpay
- Template 1: Laravel adminlte template
- MySQL