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