mirror of
https://github.com/10h30/Test-Laravel-Validation.git
synced 2026-06-05 15:07:56 +09:00
23 lines
538 B
PHP
23 lines
538 B
PHP
|
|
<?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';
|
||
|
|
}
|
||
|
|
}
|