Validate TagController's create function
MODIFY
app/Http/Controllers/TagController.php
app/Http/Controllers/TagController.php
@@ -19,11 +19,13 @@ class TagController extends Controller {
}
public function store(Request $request) {
- $tag = new Tag;
+ $this->validate([
+ 'name' => 'required|max:255'
+ ]);
+ $tag = new Tag;
$tag->user_id = Auth::user()->id;
$tag->name = $request->name;
-
$tag->save();
return redirect('/settings');

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

Validate TagController's create function