Validate input of update function in TagController
MODIFY
app/Http/Controllers/TagController.php
app/Http/Controllers/TagController.php
@@ -34,11 +34,14 @@ class TagController extends Controller {
}
public function update(Request $request, Tag $tag) {
- $tag->name = $request->input('name');
+ $request->validate([
+ 'name' => 'required|max:255'
+ ]);
+ $tag->name = $request->input('name');
$tag->save();
- return redirect()->route('tags');
+ return redirect()->route('tags.index');
}
public function destroy(Tag $tag) {

MODIFY
resources/views/tags/edit.blade.php
resources/views/tags/edit.blade.php
<div class="input input--small">
<label>Name</label>
<input type="text" name="name" value="{{ $tag->name }}" />
+ @include('partials.validation_error', ['payload' => 'name'])
</div>
</div>
<div class="box__section row row--right">

Validate input of update function in TagController