mirror of
https://github.com/10h30/Test-Laravel-Validation.git
synced 2026-06-05 15:07:56 +09:00
Task 2 - array validation
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
public function update(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
// TASK: imagine that in the Blade the fields are
|
||||
// <input name="profile[name]" ... />
|
||||
// <input name="profile[email]" ... />
|
||||
// Write validation rules, so both name and email are required
|
||||
]);
|
||||
|
||||
auth()->user()->update($request->profile ?? []);
|
||||
|
||||
return 'Success';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user