Files
Test-Laravel-Validation/app/Http/Controllers/ProfileController.php
T

25 lines
622 B
PHP
Raw Normal View History

2021-11-29 12:52:36 +02:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ProfileController extends Controller
{
public function update(Request $request)
{
$request->validate([
2025-04-21 13:06:16 +09:00
'profile.name' => 'required',
'profile.email' => 'required'
2021-11-29 12:52:36 +02:00
// 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';
}
}