mirror of
https://github.com/10h30/Test-Laravel-Auth-Basics.git
synced 2026-06-05 15:07:43 +09:00
complete all tasks
This commit is contained in:
@@ -37,7 +37,7 @@ class RegisteredUserController extends Controller
|
||||
$request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()->letters()],
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ProfileUpdateRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
@@ -11,10 +15,27 @@ class ProfileController extends Controller
|
||||
return view('auth.profile');
|
||||
}
|
||||
|
||||
|
||||
public function update(ProfileUpdateRequest $request)
|
||||
{
|
||||
// Task: fill in the code here to update name and email
|
||||
// Also, update the password if it is set
|
||||
$validated = request()->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email', Rule::unique('users')->ignore(Auth::user())],
|
||||
'password' => ['sometimes', 'nullable', 'confirmed', Password::defaults()],
|
||||
]);
|
||||
//dd($validated);
|
||||
Auth::user()->update([
|
||||
'name' => $validated['name'],
|
||||
'email' => $validated['email'],
|
||||
]);
|
||||
|
||||
if (isset($validated['password'])) {
|
||||
Auth::user()->update([
|
||||
'password' => Hash::make($validated['password']),
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('profile.show')->with('success', 'Profile updated.');
|
||||
}
|
||||
|
||||
+22
-26
@@ -1,28 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">./app</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="DB_CONNECTION" value="sqlite"/>
|
||||
<env name="DB_DATABASE" value=":memory:"/>
|
||||
<env name="MAIL_MAILER" value="array"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||
</php>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="DB_CONNECTION" value="sqlite"/>
|
||||
<env name="DB_DATABASE" value=":memory:"/>
|
||||
<env name="MAIL_MAILER" value="array"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||
</php>
|
||||
<source>
|
||||
<include>
|
||||
<directory suffix=".php">./app</directory>
|
||||
</include>
|
||||
</source>
|
||||
</phpunit>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">./app</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="DB_CONNECTION" value="sqlite"/>
|
||||
<env name="DB_DATABASE" value=":memory:"/>
|
||||
<env name="MAIL_MAILER" value="array"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
@@ -29,7 +29,7 @@
|
||||
class="block mt-1 w-full"
|
||||
type="text"
|
||||
name="name"
|
||||
value="???"
|
||||
value="{{ Auth::user()->name }}"
|
||||
required />
|
||||
</div>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
class="block mt-1 w-full"
|
||||
type="email"
|
||||
name="email"
|
||||
value="???"
|
||||
value="{{ Auth::user()->email }}"
|
||||
required />
|
||||
</div>
|
||||
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
{{ __('Users') }}
|
||||
</x-nav-link>
|
||||
{{-- Task: this "Profile" link should be visible only to logged-in users --}}
|
||||
<x-nav-link href="/profile" :active="request()->routeIs('profile.show')">
|
||||
{{ __('Profile') }}
|
||||
</x-nav-link>
|
||||
@auth
|
||||
<x-nav-link href="/profile" :active="request()->routeIs('profile.show')">
|
||||
{{ __('Profile') }}
|
||||
</x-nav-link>
|
||||
@endauth
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user