Skip to content

Instantly share code, notes, and snippets.


JeffreyWay/ProjectsController.php Secret

Last active Aug 5, 2020
What would you like to do?
Laravel From Scratch: Episode 15 - Two Layers of Validation
<h1 class="title">Create a New Project</h1>
<form method="POST" action="/projects">
<div class="field">
<label class="label" for="title">Project Title</label>
<div class="control">
class="input {{ $errors->has('title') ? 'is-danger' : '' }}"
value="{{ old('title') }}"
<div class="field">
<label class="label" for="description">Project Description</label>
<div class="control">
class="textarea {{ $errors->has('description') ? 'is-danger' : '' }}"
{{ old('description') }}
<div class="field">
<div class="control">
<button type="submit" class="button is-link">Create Project</button>
@if ($errors->any())
<div class="notification is-danger">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
public function store()
$attributes = request()->validate([
'title' => ['required', 'min:3'],
'description' => ['required', 'min:3']
return redirect('/projects');

This comment has been minimized.

Copy link

@Christonit Christonit commented Dec 6, 2018

Greetings, I've been following step by step your tutorials but somehow in this part validation isnt working: when I submit the wrong values on purposes $errors doesn't show on my view on return.

Any idea why this might be happening?


This comment has been minimized.

Copy link

@prashant1k99 prashant1k99 commented Dec 9, 2018

It's better to first test via console or try Laravel's Telescope to debug and check what's the problem.
You can find documentation about Telescope here.


This comment has been minimized.

Copy link

@MohammedMohammedBayomy MohammedMohammedBayomy commented Jan 30, 2019


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.