diff --git a/app/Http/Controllers/PostController.php b/app/Http/Controllers/PostController.php
index cd0808b7..81747ff5 100644
--- a/app/Http/Controllers/PostController.php
+++ b/app/Http/Controllers/PostController.php
@@ -12,6 +12,9 @@ public function store(Request $request)
$request->validate(
// ... TASK: write validation here so that "title" field
// would be required and unique in the "posts" DB table
+ [
+ 'title' => 'required|unique:posts'
+ ]
);
// Saving the post
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index bb6bab39..e579c8dc 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -13,6 +13,7 @@ public function update(Request $request)
//
//
// Write validation rules, so both name and email are required
+ 'profile.name' => 'required',
]);
auth()->user()->update($request->profile ?? []);
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index 404d7471..0523664a 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -11,7 +11,7 @@ public function update(User $user, UpdateUserRequest $request)
{
// TASK: change this line to not allow is_admin field to be updated
// Update only the fields that are validated in UpdateUserRequest
- $user->update($request->all());
+ $user->update($request->except('is_admin'));
return 'Success';
}
diff --git a/app/Http/Requests/StoreBuildingRequest.php b/app/Http/Requests/StoreBuildingRequest.php
index fbd8c064..a917fbff 100644
--- a/app/Http/Requests/StoreBuildingRequest.php
+++ b/app/Http/Requests/StoreBuildingRequest.php
@@ -30,4 +30,11 @@ public function rules()
'name' => 'required'
];
}
+
+ public function messages()
+ {
+ return [
+ 'name.required' => 'Please enter the name'
+ ];
+ }
}
diff --git a/app/Http/Requests/StoreItemRequest.php b/app/Http/Requests/StoreItemRequest.php
new file mode 100644
index 00000000..dd49c6f4
--- /dev/null
+++ b/app/Http/Requests/StoreItemRequest.php
@@ -0,0 +1,29 @@
+
+ */
+ public function rules(): array
+ {
+ return [
+ 'name' => ['required'],
+ 'description' => ['required'],
+ ];
+ }
+}
diff --git a/app/Rules/StoreItemRequest.php b/app/Rules/StoreItemRequest.php
new file mode 100644
index 00000000..3fb6193b
--- /dev/null
+++ b/app/Rules/StoreItemRequest.php
@@ -0,0 +1,19 @@
+{{ $message }}
+ @enderror
diff --git a/resources/views/projects/create.blade.php b/resources/views/projects/create.blade.php
index dc19b63b..7cd21598 100644
--- a/resources/views/projects/create.blade.php
+++ b/resources/views/projects/create.blade.php
@@ -6,6 +6,15 @@