diff --git a/README.md b/README.md
index 5f5d63e..e62adb8 100644
--- a/README.md
+++ b/README.md
@@ -48,3 +48,11 @@ Test method `test_array_validation()`.
---
+## Task 3. Showing Validation Errors.
+
+In `resources/views/projects/create.blade.php` file, show the validation errors, for `"name" => "required", "description" => "required"` rules. Use whatever HTML structure you want, like `
`. No design needed, the test will just check if the error messages are present.
+
+Test method `test_validation_errors_shown_in_blade()`.
+
+---
+
diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php
new file mode 100644
index 0000000..16f3d5c
--- /dev/null
+++ b/app/Http/Controllers/ProjectController.php
@@ -0,0 +1,32 @@
+all(), [
+ 'name' => 'required',
+ 'description' => 'required'
+ ]);
+
+ if ($validator->fails()) {
+ return redirect('projects/create')
+ ->withErrors($validator);
+ }
+
+ Project::create($validator->validated());
+
+ return 'Success';
+ }
+}
diff --git a/app/Models/Project.php b/app/Models/Project.php
new file mode 100644
index 0000000..7e08476
--- /dev/null
+++ b/app/Models/Project.php
@@ -0,0 +1,13 @@
+id();
+ $table->string('name');
+ $table->string('description');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('projects');
+ }
+}
diff --git a/resources/views/projects/create.blade.php b/resources/views/projects/create.blade.php
new file mode 100644
index 0000000..dc19b63
--- /dev/null
+++ b/resources/views/projects/create.blade.php
@@ -0,0 +1,18 @@
+{{-- Form without any design --}}
+
+{{-- TASK: add the validation errors here - with whatever HTML structure you want --}}
+{{-- in case of title/description empty, visitor should see --}}
+{{-- "The name field is required." and "The description field is required." --}}
+
+
diff --git a/routes/web.php b/routes/web.php
index 74900d4..662f268 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -15,6 +15,7 @@ use Illuminate\Support\Facades\Route;
Route::post('posts', [\App\Http\Controllers\PostController::class, 'store']);
Route::post('profile', [\App\Http\Controllers\ProfileController::class, 'update'])->middleware('auth');
+Route::resource('projects', \App\Http\Controllers\ProjectController::class);
Route::get('/', function () {
return view('welcome');
diff --git a/tests/Feature/ValidationTest.php b/tests/Feature/ValidationTest.php
index 3a9c647..3945d43 100644
--- a/tests/Feature/ValidationTest.php
+++ b/tests/Feature/ValidationTest.php
@@ -42,4 +42,13 @@ class ValidationTest extends TestCase
]);
$response->assertStatus(200);
}
+
+ public function test_validation_errors_shown_in_blade()
+ {
+ // Post without name and description should fail
+ $response = $this->followingRedirects()->post('projects');
+ $response->assertStatus(200);
+ $response->assertSee('The name field is required.');
+ $response->assertSee('The description field is required.');
+ }
}