profile edit with personal moto and social media links

This commit is contained in:
ghassan committed 2026-01-20 23:29:45 +03:00
1 parent af567c2c5f
commit 5cbb26608c
19 files changed
+4415 -102

No files matched your search

@@ -26,11 +26,20 @@ class AuthenticatedSessionController extends Controller
*/
public function store(Request $request)
{
$credentials = $request->validate([
'email' => ['required', 'email'],
$request->validate([
'email' => ['required'],
'password' => ['required'],
]);
if (filter_var($request->email, FILTER_VALIDATE_EMAIL)) {
$field = 'email';
$value = $request->email;
} else {
$field = 'mobile';
$value = trim(preg_replace('/[^\d\+]/', '', $request->email)); // Keep digits and +, trim
}
$credentials = [$field => $value, 'password' => $request->password];
if (Auth::attempt($credentials)) {
$request->session()->regenerate();
+98
View File
@@ -56,6 +56,104 @@ class FamilyController extends Controller
]);
}
/**
* Show the form for editing the current user's profile.
*
* @return \Illuminate\View\View
*/
public function editProfile()
{
$user = Auth::user();
return view('family.profile-edit', compact('user'));
}
/**
* Upload profile picture for the current user.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function uploadProfilePicture(Request $request)
{
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif|max:5120', // 5MB max
]);
$user = Auth::user();
if ($request->hasFile('image')) {
$image = $request->file('image');
// Generate unique filename
$filename = 'profile_' . $user->id . '_' . time() . '.' . $image->getClientOriginalExtension();
// Store in public/images/profiles
$path = $image->storeAs('images/profiles', $filename, 'public');
// Delete old profile picture if exists
if ($user->profile_picture && \Storage::disk('public')->exists($user->profile_picture)) {
\Storage::disk('public')->delete($user->profile_picture);
}
// Update user
$user->update(['profile_picture' => $path]);
return response()->json([
'success' => true,
'message' => 'Profile picture uploaded successfully.',
'path' => $path,
]);
}
return response()->json([
'success' => false,
'message' => 'No image file provided.',
], 400);
}
/**
* Update the current user's profile in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function updateProfile(Request $request)
{
$validated = $request->validate([
'full_name' => 'required|string|max:255',
'email' => 'required|email|max:255|unique:users,email,' . Auth::id(),
'mobile' => 'nullable|string|max:20',
'gender' => 'required|in:m,f',
'birthdate' => 'required|date',
'blood_type' => 'nullable|string|max:10',
'nationality' => 'required|string|max:100',
'social_links' => 'nullable|array',
'social_links.*.platform' => 'required_with:social_links.*.url|string',
'social_links.*.url' => 'required_with:social_links.*.platform|url',
'motto' => 'nullable|string|max:500',
]);
$user = Auth::user();
// Process social links - convert from array of objects to associative array
$socialLinks = [];
if (isset($validated['social_links']) && is_array($validated['social_links'])) {
foreach ($validated['social_links'] as $link) {
if (!empty($link['platform']) && !empty($link['url'])) {
$socialLinks[$link['platform']] = $link['url'];
}
}
}
$validated['social_links'] = $socialLinks;
$user->update($validated);
return redirect()->route('profile.show')
->with('success', 'Profile updated successfully.');
}
/**
* Show the form for creating a new family member.
*
+7
View File
@@ -7,6 +7,7 @@ use App\Models\UserRelationship;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Support\Facades\URL;
class WelcomeEmail extends Mailable
{
@@ -68,6 +69,12 @@ class WelcomeEmail extends Mailable
{
return new Content(
view: 'emails.welcome',
with: [
'verificationUrl' => URL::temporarySignedRoute('verification.verify', now()->addMinutes(60), [
'id' => $this->user->getKey(),
'hash' => sha1($this->user->getEmailForVerification()),
]),
],
);
}
+12
View File
@@ -35,6 +35,8 @@ class User extends Authenticatable
'addresses',
'social_links',
'media_gallery',
'profile_picture',
'motto',
];
/**
@@ -199,4 +201,14 @@ class User extends Authenticatable
{
return $this->hasMany(Invoice::class, 'payer_user_id');
}
/**
* Send the email verification notification.
* Override to prevent sending the default Laravel notification.
* We send our custom welcome email instead.
*/
public function sendEmailVerificationNotification()
{
// Do nothing - we handle verification via welcome email
}
}