mirror of
https://github.com/10h30/Test-Laravel-Validation.git
synced 2026-06-05 15:07:56 +09:00
Complete all tasks
This commit is contained in:
@@ -9,14 +9,14 @@ class PostController extends Controller
|
||||
{
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate(
|
||||
$request->validate([
|
||||
'title' => 'required|unique:posts'
|
||||
// ... TASK: write validation here so that "title" field
|
||||
// would be required and unique in the "posts" DB table
|
||||
);
|
||||
]);
|
||||
|
||||
// Saving the post
|
||||
Post::create(['title' => $request->title]);
|
||||
|
||||
return 'Success';
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -9,6 +9,8 @@ class ProfileController extends Controller
|
||||
public function update(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'profile.name' => 'required',
|
||||
'profile.email' => 'required'
|
||||
// TASK: imagine that in the Blade the fields are
|
||||
// <input name="profile[name]" ... />
|
||||
// <input name="profile[email]" ... />
|
||||
|
||||
@@ -11,7 +11,7 @@ class UserController extends Controller
|
||||
{
|
||||
// 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';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user