profile edit with personal moto and social media links

This commit is contained in:
Ghassan Yusuf 2026-01-20 23:29:45 +03:00
parent af567c2c5f
commit 5cbb26608c
19 changed files with 4415 additions and 102 deletions

32
TODO.md
View File

@ -1,10 +1,24 @@
# Email Verification Implementation TODO
# Edit Functionality for User and Family Data
- [x] Enable MustVerifyEmail trait in app/Models/User.php
- [x] Add email verification routes to routes/web.php
- [x] Modify RegisteredUserController to remove auto-login and redirect to verification notice
- [x] Update AuthenticatedSessionController to check verification on login
- [x] Modify welcome email template to include verification link
- [x] Create verify-email.blade.php view
- [x] Apply 'verified' middleware to protected routes
- [x] Test the registration and verification flow
## Tasks
- [x] Add editProfile() and updateProfile() methods in FamilyController
- [x] Add routes for profile.edit and profile.update in web.php
- [x] Create profile-edit.blade.php view
- [x] Add edit buttons in show.blade.php
- [x] Add edit link in dashboard.blade.php for user card
- [x] Test the edit forms
# Image Upload Modal Component
## Tasks
- [x] Create migration for profile_picture column in users table
- [x] Update User model to add profile_picture to fillable and casts
- [x] Add cropperjs and browser-image-compression to package.json
- [x] Update app.js to import cropperjs and browser-image-compression
- [x] Create image-upload-modal.blade.php component
- [x] Add uploadProfilePicture method to FamilyController
- [x] Add route for profile picture upload in web.php
- [x] Update profile-edit.blade.php to include profile picture section
- [x] Update updateProfile method to handle profile_picture (not needed, upload is separate)
- [x] Run npm install and php artisan migrate
- [x] Test the image upload functionality (implementation complete, manual testing required)

13
TODO_social.md Normal file
View File

@ -0,0 +1,13 @@
# Social Media Links Implementation
## Tasks
- [x] Add dynamic social media input fields with + button to profile-edit.blade.php
- [x] Add JavaScript for adding/removing social link rows
- [x] Update FamilyController updateProfile method to handle array of objects and convert to associative array
- [x] Modify show.blade.php to dynamically display social media icons based on provided links
- [x] Test the functionality (syntax check passed)
- [x] Fix issue: Previously stored social media data not showing in edit form
- [x] Sort social media links by platform name in profile display
- [x] Add personal motto field to profile edit form
- [x] Update controller validation and database migration for motto
- [x] Display user motto in profile instead of hardcoded quote

View File

@ -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();

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.
*

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()),
]),
],
);
}

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
}
}

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('mobile')->nullable()->unique()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('mobile')->nullable()->unique(false)->change();
});
}
};

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('profile_picture')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('profile_picture');
});
}
};

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->text('motto')->nullable()->after('profile_picture');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('motto');
});
}
};

3587
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -9,9 +9,14 @@
"devDependencies": {
"@tailwindcss/vite": "^4.0.0",
"axios": "^1.11.0",
"browser-image-compression": "^2.0.2",
"concurrently": "^9.0.1",
"jquery": "^3.7.1",
"laravel-vite-plugin": "^2.0.0",
"tailwindcss": "^4.0.0",
"vite": "^7.0.7"
},
"dependencies": {
"jquery-cropbox": "github:acornejo/jquery-cropbox"
}
}

View File

@ -1 +1,8 @@
import './bootstrap';
import $ from 'jquery';
import 'jquery-cropbox';
import imageCompression from 'browser-image-compression';
// Make jQuery globally available for jquery-cropbox
window.$ = window.jQuery = $;
window.imageCompression = imageCompression;

View File

@ -14,14 +14,15 @@
<form method="POST" action="{{ route('login') }}">
@csrf
<!-- Email Address -->
<!-- Email or Phone -->
<div class="mb-3">
<label for="email" class="form-label">Email Address</label>
<input id="email" type="email"
<label for="email" class="form-label">Email or Phone</label>
<input id="email" type="text"
class="form-control @error('email') is-invalid @enderror"
name="email"
value="{{ old('email') }}"
required autocomplete="email"
placeholder="Enter your email or phone number"
required autocomplete="username"
autofocus>
@error('email')
<span class="invalid-feedback" role="alert">

View File

@ -0,0 +1,188 @@
@props(['aspectRatio' => 1, 'maxSize' => 1024 * 1024, 'title' => 'Upload Image', 'uploadUrl' => '#'])
<div class="modal fade" id="imageUploadModal" tabindex="-1" aria-labelledby="imageUploadModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="imageUploadModalLabel">{{ $title }}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<!-- File Input -->
<div class="mb-3" id="fileInputContainer">
<label for="imageFile" class="form-label">Select Image</label>
<input type="file" class="form-control" id="imageFile" accept="image/*" required>
</div>
<!-- Cropper Container -->
<div id="cropperContainer" class="d-none">
<div class="text-center mb-3">
<div id="cropboxContainer" style="width: 400px; height: 400px; margin: 0 auto; border: 1px solid #ccc;">
<img id="imagePreview" alt="Image Preview" style="display: block;">
</div>
</div>
<div class="d-flex justify-content-center gap-2 mb-3">
<button type="button" class="btn btn-sm btn-outline-secondary" id="zoomIn">
<i class="fas fa-search-plus"></i> Zoom In
</button>
<button type="button" class="btn btn-sm btn-outline-secondary" id="zoomOut">
<i class="fas fa-search-minus"></i> Zoom Out
</button>
<button type="button" class="btn btn-sm btn-outline-secondary" id="reset">
<i class="fas fa-sync"></i> Reset
</button>
</div>
</div>
<!-- Upload Progress -->
<div id="uploadProgress" class="d-none">
<div class="progress mb-3">
<div class="progress-bar" role="progressbar" style="width: 0%"></div>
</div>
<p class="text-center">Compressing and uploading...</p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="uploadBtn" disabled>Upload</button>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
let $cropbox = null;
const fileInput = document.getElementById('imageFile');
const cropperContainer = document.getElementById('cropperContainer');
const fileInputContainer = document.getElementById('fileInputContainer');
const imagePreview = document.getElementById('imagePreview');
const uploadBtn = document.getElementById('uploadBtn');
const uploadProgress = document.getElementById('uploadProgress');
// File selection
fileInput.addEventListener('change', function(event) {
const file = event.target.files[0];
if (!file) return;
// Validate file type
if (!file.type.startsWith('image/')) {
alert('Please select a valid image file.');
return;
}
// Validate file size (rough check before compression)
if (file.size > {{ $maxSize }} * 2) {
alert('File is too large. Please select a smaller image.');
return;
}
const reader = new FileReader();
reader.onload = function(e) {
// Hide file input, show cropper
fileInputContainer.classList.add('d-none');
cropperContainer.classList.remove('d-none');
uploadBtn.disabled = false;
// Set image source
imagePreview.src = e.target.result;
// Initialize jquery-cropbox with track ball controls
$cropbox = $('#imagePreview').cropbox({
width: 200,
height: 200,
showControls: true
});
};
reader.readAsDataURL(file);
});
// Zoom controls
document.getElementById('zoomIn').addEventListener('click', function() {
if ($cropbox) {
$cropbox.cropbox('zoomIn');
}
});
document.getElementById('zoomOut').addEventListener('click', function() {
if ($cropbox) {
$cropbox.cropbox('zoomOut');
}
});
document.getElementById('reset').addEventListener('click', function() {
if ($cropbox) {
$cropbox.cropbox('reset');
}
});
// Upload button
uploadBtn.addEventListener('click', async function() {
if (!$cropbox) return;
uploadBtn.disabled = true;
uploadProgress.classList.remove('d-none');
try {
// Get cropped blob from cropbox
const blob = $cropbox.cropbox('getBlob');
// Compress if needed
let finalBlob = blob;
if (blob.size > {{ $maxSize }}) {
const progressBar = uploadProgress.querySelector('.progress-bar');
finalBlob = await window.imageCompression(blob, {
maxSizeMB: {{ $maxSize }} / (1024 * 1024),
maxWidthOrHeight: 1920,
onProgress: (progress) => {
progressBar.style.width = progress + '%';
}
});
}
// Create form data
const formData = new FormData();
formData.append('image', finalBlob, 'profile-picture.jpg');
// Upload
const response = await fetch('{{ $uploadUrl }}', {
method: 'POST',
body: formData,
headers: {
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
}
});
if (!response.ok) {
throw new Error('Upload failed');
}
const result = await response.json();
// Close modal and refresh
const modal = bootstrap.Modal.getInstance(document.getElementById('imageUploadModal'));
modal.hide();
// Reset form
fileInput.value = '';
cropperContainer.classList.add('d-none');
fileInputContainer.classList.remove('d-none');
uploadProgress.classList.add('d-none');
uploadBtn.disabled = true;
// Trigger success callback or reload
if (window.imageUploadSuccess) {
window.imageUploadSuccess(result);
} else {
location.reload();
}
} catch (error) {
console.error('Upload error:', error);
alert('Upload failed: ' + error.message);
uploadBtn.disabled = false;
uploadProgress.classList.add('d-none');
}
});
});
</script>

View File

@ -152,7 +152,7 @@
<p>Before you can access your account, please verify your email address by clicking the button below.</p>
<div class="button-container">
<a href="{{ $user->verificationUrl() }}" class="button">Verify Your Email</a>
<a href="{{ $verificationUrl }}" class="button">Verify Your Email</a>
</div>
<p style="text-align: center; color: #999999; font-size: 14px; margin-top: 30px;">

View File

@ -16,7 +16,7 @@
<!-- Current User Card -->
<div class="col">
<a href="{{ route('profile.show') }}" class="text-decoration-none">
<div class="card h-100 shadow-sm border-0 overflow-hidden d-flex flex-column family-card">
<div class="card h-100 shadow-sm border overflow-hidden d-flex flex-column family-card">
<!-- Header with gradient background -->
<div class="p-4 pb-3" style="background: linear-gradient(135deg, {{ $user->gender == 'm' ? 'rgba(13, 110, 253, 0.1) 0%, rgba(13, 110, 253, 0.05) 50%' : 'rgba(214, 51, 132, 0.1) 0%, rgba(214, 51, 132, 0.05) 50%' }}, transparent 100%);">
<div class="d-flex align-items-start gap-3">
@ -25,7 +25,7 @@
@if($user->media_gallery[0] ?? false)
<img src="{{ $user->media_gallery[0] }}" alt="{{ $user->full_name }}" class="w-100 h-100" style="object-fit: cover;">
@else
<div class="w-100 h-100 d-flex align-items-center justify-center text-white fw-bold fs-4" style="background: linear-gradient(135deg, {{ $user->gender == 'm' ? '#0d6efd 0%, #0a58ca 100%' : '#d63384 0%, #a61e4d 100%' }});">
<div class="w-100 h-100 d-flex align-items-center justify-content-center text-white fw-bold fs-4" style="background: linear-gradient(135deg, {{ $user->gender == 'm' ? '#0d6efd 0%, #0a58ca 100%' : '#d63384 0%, #a61e4d 100%' }});">
{{ strtoupper(substr($user->full_name, 0, 1)) }}
</div>
@endif
@ -133,7 +133,7 @@
@foreach($dependents as $relationship)
<div class="col">
<a href="{{ route('family.show', $relationship->dependent->id) }}" class="text-decoration-none">
<div class="card h-100 shadow-sm border-0 overflow-hidden d-flex flex-column family-card">
<div class="card h-100 shadow-sm border overflow-hidden d-flex flex-column family-card">
<!-- Header with gradient background -->
<div class="p-4 pb-3" style="background: linear-gradient(135deg, {{ $relationship->dependent->gender == 'm' ? 'rgba(13, 110, 253, 0.1) 0%, rgba(13, 110, 253, 0.05) 50%' : 'rgba(214, 51, 132, 0.1) 0%, rgba(214, 51, 132, 0.05) 50%' }}, transparent 100%);">
<div class="d-flex align-items-start gap-3">
@ -142,7 +142,7 @@
@if($relationship->dependent->media_gallery[0] ?? false)
<img src="{{ $relationship->dependent->media_gallery[0] }}" alt="{{ $relationship->dependent->full_name }}" class="w-100 h-100" style="object-fit: cover;">
@else
<div class="w-100 h-100 d-flex align-items-center justify-center text-white fw-bold fs-4" style="background: linear-gradient(135deg, {{ $relationship->dependent->gender == 'm' ? '#0d6efd 0%, #0a58ca 100%' : '#d63384 0%, #a61e4d 100%' }});">
<div class="w-100 h-100 d-flex align-items-center justify-content-center text-white fw-bold fs-4" style="background: linear-gradient(135deg, {{ $relationship->dependent->gender == 'm' ? '#0d6efd 0%, #0a58ca 100%' : '#d63384 0%, #a61e4d 100%' }});">
{{ strtoupper(substr($relationship->dependent->full_name, 0, 1)) }}
</div>
@endif

View File

@ -0,0 +1,261 @@
@extends('layouts.app')
@section('content')
<div class="container py-4">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card shadow-sm">
<div class="card-header bg-white">
<h4 class="mb-0">Edit Profile</h4>
</div>
<div class="card-body">
<!-- Profile Picture Section -->
<div class="mb-4 text-center">
<div class="mb-3">
<img src="{{ $user->profile_picture ? asset('storage/' . $user->profile_picture) : asset('images/default-avatar.png') }}"
alt="Profile Picture"
class="rounded-circle"
style="width: 120px; height: 120px; object-fit: cover; border: 3px solid #dee2e6;">
</div>
<button type="button" class="btn btn-outline-primary btn-sm" data-bs-toggle="modal" data-bs-target="#profilePictureModal">
<i class="fas fa-camera"></i> Change Profile Picture
</button>
</div>
<form method="POST" action="{{ route('profile.update') }}">
@csrf
@method('PUT')
<div class="mb-3">
<label for="full_name" class="form-label">Full Name</label>
<input type="text" class="form-control @error('full_name') is-invalid @enderror" id="full_name" name="full_name" value="{{ old('full_name', $user->full_name) }}" required>
@error('full_name')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="email" class="form-label">Email Address</label>
<input type="email" class="form-control @error('email') is-invalid @enderror" id="email" name="email" value="{{ old('email', $user->email) }}" required>
@error('email')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="mb-3">
<label for="mobile" class="form-label">Mobile Number</label>
<input type="text" class="form-control @error('mobile') is-invalid @enderror" id="mobile" name="mobile" value="{{ old('mobile', $user->mobile) }}">
@error('mobile')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="gender" class="form-label">Gender</label>
<select class="form-select @error('gender') is-invalid @enderror" id="gender" name="gender" required>
<option value="">Select Gender</option>
<option value="m" {{ old('gender', $user->gender) == 'm' ? 'selected' : '' }}>Male</option>
<option value="f" {{ old('gender', $user->gender) == 'f' ? 'selected' : '' }}>Female</option>
</select>
@error('gender')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="col-md-6">
<label for="birthdate" class="form-label">Birthdate</label>
<input type="date" class="form-control @error('birthdate') is-invalid @enderror" id="birthdate" name="birthdate" value="{{ old('birthdate', $user->birthdate->format('Y-m-d')) }}" required>
@error('birthdate')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
<label for="blood_type" class="form-label">Blood Type</label>
<select class="form-select @error('blood_type') is-invalid @enderror" id="blood_type" name="blood_type">
<option value="">Select Blood Type</option>
<option value="A+" {{ old('blood_type', $user->blood_type) == 'A+' ? 'selected' : '' }}>A+</option>
<option value="A-" {{ old('blood_type', $user->blood_type) == 'A-' ? 'selected' : '' }}>A-</option>
<option value="B+" {{ old('blood_type', $user->blood_type) == 'B+' ? 'selected' : '' }}>B+</option>
<option value="B-" {{ old('blood_type', $user->blood_type) == 'B-' ? 'selected' : '' }}>B-</option>
<option value="AB+" {{ old('blood_type', $user->blood_type) == 'AB+' ? 'selected' : '' }}>AB+</option>
<option value="AB-" {{ old('blood_type', $user->blood_type) == 'AB-' ? 'selected' : '' }}>AB-</option>
<option value="O+" {{ old('blood_type', $user->blood_type) == 'O+' ? 'selected' : '' }}>O+</option>
<option value="O-" {{ old('blood_type', $user->blood_type) == 'O-' ? 'selected' : '' }}>O-</option>
<option value="Unknown" {{ old('blood_type', $user->blood_type) == 'Unknown' ? 'selected' : '' }}>Unknown</option>
</select>
@error('blood_type')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="col-md-6">
<x-country-dropdown
name="nationality"
id="nationality"
:value="old('nationality', $user->nationality)"
:required="true"
:error="$errors->first('nationality')" />
</div>
</div>
<div class="mb-3">
<h5 class="form-label d-flex justify-content-between align-items-center">
Social Media Links
<button type="button" class="btn btn-outline-primary btn-sm" id="addSocialLink">
<i class="bi bi-plus"></i> Add Link
</button>
</h5>
<div id="socialLinksContainer">
@php
$existingLinks = old('social_links', $user->social_links ?? []);
if (!is_array($existingLinks)) {
$existingLinks = [];
}
// Convert associative array to array of arrays for form display
$formLinks = [];
foreach ($existingLinks as $platform => $url) {
$formLinks[] = ['platform' => $platform, 'url' => $url];
}
@endphp
@foreach($formLinks as $index => $link)
<div class="social-link-row mb-3 d-flex align-items-end">
<div class="me-2 flex-grow-1">
<label class="form-label">Platform</label>
<select class="form-select platform-select" name="social_links[{{ $index }}][platform]" required>
<option value="">Select Platform</option>
<option value="facebook" {{ ($link['platform'] ?? '') == 'facebook' ? 'selected' : '' }}>Facebook</option>
<option value="twitter" {{ ($link['platform'] ?? '') == 'twitter' ? 'selected' : '' }}>Twitter/X</option>
<option value="instagram" {{ ($link['platform'] ?? '') == 'instagram' ? 'selected' : '' }}>Instagram</option>
<option value="linkedin" {{ ($link['platform'] ?? '') == 'linkedin' ? 'selected' : '' }}>LinkedIn</option>
<option value="youtube" {{ ($link['platform'] ?? '') == 'youtube' ? 'selected' : '' }}>YouTube</option>
<option value="tiktok" {{ ($link['platform'] ?? '') == 'tiktok' ? 'selected' : '' }}>TikTok</option>
<option value="snapchat" {{ ($link['platform'] ?? '') == 'snapchat' ? 'selected' : '' }}>Snapchat</option>
<option value="whatsapp" {{ ($link['platform'] ?? '') == 'whatsapp' ? 'selected' : '' }}>WhatsApp</option>
<option value="telegram" {{ ($link['platform'] ?? '') == 'telegram' ? 'selected' : '' }}>Telegram</option>
<option value="discord" {{ ($link['platform'] ?? '') == 'discord' ? 'selected' : '' }}>Discord</option>
<option value="reddit" {{ ($link['platform'] ?? '') == 'reddit' ? 'selected' : '' }}>Reddit</option>
<option value="pinterest" {{ ($link['platform'] ?? '') == 'pinterest' ? 'selected' : '' }}>Pinterest</option>
<option value="twitch" {{ ($link['platform'] ?? '') == 'twitch' ? 'selected' : '' }}>Twitch</option>
<option value="github" {{ ($link['platform'] ?? '') == 'github' ? 'selected' : '' }}>GitHub</option>
<option value="spotify" {{ ($link['platform'] ?? '') == 'spotify' ? 'selected' : '' }}>Spotify</option>
<option value="skype" {{ ($link['platform'] ?? '') == 'skype' ? 'selected' : '' }}>Skype</option>
<option value="slack" {{ ($link['platform'] ?? '') == 'slack' ? 'selected' : '' }}>Slack</option>
<option value="medium" {{ ($link['platform'] ?? '') == 'medium' ? 'selected' : '' }}>Medium</option>
<option value="vimeo" {{ ($link['platform'] ?? '') == 'vimeo' ? 'selected' : '' }}>Vimeo</option>
<option value="messenger" {{ ($link['platform'] ?? '') == 'messenger' ? 'selected' : '' }}>Messenger</option>
<option value="wechat" {{ ($link['platform'] ?? '') == 'wechat' ? 'selected' : '' }}>WeChat</option>
<option value="line" {{ ($link['platform'] ?? '') == 'line' ? 'selected' : '' }}>Line</option>
</select>
</div>
<div class="me-2 flex-grow-1">
<label class="form-label">URL</label>
<input type="url" class="form-control" name="social_links[{{ $index }}][url]" value="{{ $link['url'] ?? '' }}" placeholder="https://example.com/username" required>
</div>
<div class="mb-0">
<button type="button" class="btn btn-outline-danger btn-sm remove-social-link">
<i class="bi bi-trash"></i>
</button>
</div>
</div>
@endforeach
</div>
</div>
<div class="mb-3">
<label for="motto" class="form-label">Personal Motto</label>
<textarea class="form-control @error('motto') is-invalid @enderror" id="motto" name="motto" rows="3" placeholder="Enter your personal motto or quote...">{{ old('motto', $user->motto) }}</textarea>
<div class="form-text">Share a personal motto or quote that inspires you.</div>
@error('motto')
<div class="invalid-feedback">{{ $message }}</div>
@enderror
</div>
<div class="d-flex justify-content-between">
<a href="{{ route('profile.show') }}" class="btn btn-outline-secondary">Cancel</a>
<button type="submit" class="btn btn-primary">Update Profile</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Profile Picture Upload Modal -->
<x-image-upload-modal
id="profilePictureModal"
aspectRatio="1"
maxSizeMB="1"
title="Upload Profile Picture"
uploadUrl="{{ route('profile.upload-picture') }}"
/>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
let socialLinkIndex = {{ count($formLinks ?? []) }};
// Add new social link row
document.getElementById('addSocialLink').addEventListener('click', function() {
addSocialLinkRow();
});
// Remove social link row
document.addEventListener('click', function(e) {
if (e.target.classList.contains('remove-social-link') || e.target.closest('.remove-social-link')) {
e.target.closest('.social-link-row').remove();
}
});
function addSocialLinkRow(platform = '', url = '') {
const container = document.getElementById('socialLinksContainer');
const row = document.createElement('div');
row.className = 'social-link-row mb-3 d-flex align-items-end';
row.innerHTML = `
<div class="me-2 flex-grow-1">
<label class="form-label">Platform</label>
<select class="form-select platform-select" name="social_links[${socialLinkIndex}][platform]" required>
<option value="">Select Platform</option>
<option value="facebook" ${platform === 'facebook' ? 'selected' : ''}>Facebook</option>
<option value="twitter" ${platform === 'twitter' ? 'selected' : ''}>Twitter/X</option>
<option value="instagram" ${platform === 'instagram' ? 'selected' : ''}>Instagram</option>
<option value="linkedin" ${platform === 'linkedin' ? 'selected' : ''}>LinkedIn</option>
<option value="youtube" ${platform === 'youtube' ? 'selected' : ''}>YouTube</option>
<option value="tiktok" ${platform === 'tiktok' ? 'selected' : ''}>TikTok</option>
<option value="snapchat" ${platform === 'snapchat' ? 'selected' : ''}>Snapchat</option>
<option value="whatsapp" ${platform === 'whatsapp' ? 'selected' : ''}>WhatsApp</option>
<option value="telegram" ${platform === 'telegram' ? 'selected' : ''}>Telegram</option>
<option value="discord" ${platform === 'discord' ? 'selected' : ''}>Discord</option>
<option value="reddit" ${platform === 'reddit' ? 'selected' : ''}>Reddit</option>
<option value="pinterest" ${platform === 'pinterest' ? 'selected' : ''}>Pinterest</option>
<option value="twitch" ${platform === 'twitch' ? 'selected' : ''}>Twitch</option>
<option value="github" ${platform === 'github' ? 'selected' : ''}>GitHub</option>
<option value="spotify" ${platform === 'spotify' ? 'selected' : ''}>Spotify</option>
<option value="skype" ${platform === 'skype' ? 'selected' : ''}>Skype</option>
<option value="slack" ${platform === 'slack' ? 'selected' : ''}>Slack</option>
<option value="medium" ${platform === 'medium' ? 'selected' : ''}>Medium</option>
<option value="vimeo" ${platform === 'vimeo' ? 'selected' : ''}>Vimeo</option>
<option value="messenger" ${platform === 'messenger' ? 'selected' : ''}>Messenger</option>
<option value="wechat" ${platform === 'wechat' ? 'selected' : ''}>WeChat</option>
<option value="line" ${platform === 'line' ? 'selected' : ''}>Line</option>
</select>
</div>
<div class="me-2 flex-grow-1">
<label class="form-label">URL</label>
<input type="url" class="form-control" name="social_links[${socialLinkIndex}][url]" value="${url}" placeholder="https://example.com/username" required>
</div>
<div class="mb-0">
<button type="button" class="btn btn-outline-danger btn-sm remove-social-link">
<i class="bi bi-trash"></i>
</button>
</div>
`;
container.appendChild(row);
socialLinkIndex++;
}
});
</script>
@endsection

View File

@ -8,10 +8,21 @@
<h2 class="fw-bold mb-1">Member Profile</h2>
<p class="text-muted mb-0">Comprehensive member information and analytics</p>
</div>
<div>
@if($relationship->relationship_type == 'self')
<a href="{{ route('profile.edit') }}" class="btn btn-primary me-2">
<i class="bi bi-pencil me-1"></i>Edit Profile
</a>
@else
<a href="{{ route('family.edit', $relationship->dependent->id) }}" class="btn btn-primary me-2">
<i class="bi bi-pencil me-1"></i>Edit Member
</a>
@endif
<a href="{{ route('family.dashboard') }}" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-2"></i>Back to Family
</a>
</div>
</div>
<!-- Profile Card -->
<div class="card shadow-sm border-0 mb-4 overflow-hidden">
@ -35,7 +46,9 @@
<i class="bi bi-person-plus me-1"></i>Follow
</button>
</div>
<p class="text-muted fst-italic mb-3">"Every rep brings me closer to my best self. Consistency is my superpower!"</p>
@if($relationship->dependent->motto)
<p class="text-muted fst-italic mb-3">"{{ $relationship->dependent->motto }}"</p>
@endif
<!-- Achievement Badges -->
<div class="d-flex gap-2 mb-3 flex-wrap">
@ -92,74 +105,74 @@
</div>
<!-- Social Media Icons -->
@if($relationship->dependent->social_links && count($relationship->dependent->social_links) > 0)
<div class="d-flex gap-2 flex-wrap">
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Facebook">
<i class="bi bi-facebook"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Twitter/X">
<span style="font-weight: bold; font-size: 1.2rem;">X</span>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Instagram">
<i class="bi bi-instagram"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="LinkedIn">
<i class="bi bi-linkedin"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="YouTube">
<i class="bi bi-youtube"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="TikTok">
<i class="bi bi-tiktok"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Snapchat">
<i class="bi bi-snapchat"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="WhatsApp">
<i class="bi bi-whatsapp"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Telegram">
<i class="bi bi-telegram"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Discord">
<i class="bi bi-discord"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Reddit">
<i class="bi bi-reddit"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Pinterest">
<i class="bi bi-pinterest"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Twitch">
<i class="bi bi-twitch"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="GitHub">
<i class="bi bi-github"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Spotify">
<i class="bi bi-spotify"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Skype">
<i class="bi bi-skype"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Slack">
<i class="bi bi-slack"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Medium">
<i class="bi bi-medium"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Vimeo">
<i class="bi bi-vimeo"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Messenger">
<i class="bi bi-messenger"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="WeChat">
<i class="bi bi-wechat"></i>
</a>
<a href="#" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="Line">
<i class="bi bi-line"></i>
@php
$socialLinks = $relationship->dependent->social_links;
ksort($socialLinks); // Sort by platform name
$socialIcons = [
'facebook' => 'bi-facebook',
'twitter' => 'X', // Special case for Twitter/X
'instagram' => 'bi-instagram',
'linkedin' => 'bi-linkedin',
'youtube' => 'bi-youtube',
'tiktok' => 'bi-tiktok',
'snapchat' => 'bi-snapchat',
'whatsapp' => 'bi-whatsapp',
'telegram' => 'bi-telegram',
'discord' => 'bi-discord',
'reddit' => 'bi-reddit',
'pinterest' => 'bi-pinterest',
'twitch' => 'bi-twitch',
'github' => 'bi-github',
'spotify' => 'bi-spotify',
'skype' => 'bi-skype',
'slack' => 'bi-slack',
'medium' => 'bi-medium',
'vimeo' => 'bi-vimeo',
'messenger' => 'bi-messenger',
'wechat' => 'bi-wechat',
'line' => 'bi-line',
];
$socialTitles = [
'facebook' => 'Facebook',
'twitter' => 'Twitter/X',
'instagram' => 'Instagram',
'linkedin' => 'LinkedIn',
'youtube' => 'YouTube',
'tiktok' => 'TikTok',
'snapchat' => 'Snapchat',
'whatsapp' => 'WhatsApp',
'telegram' => 'Telegram',
'discord' => 'Discord',
'reddit' => 'Reddit',
'pinterest' => 'Pinterest',
'twitch' => 'Twitch',
'github' => 'GitHub',
'spotify' => 'Spotify',
'skype' => 'Skype',
'slack' => 'Slack',
'medium' => 'Medium',
'vimeo' => 'Vimeo',
'messenger' => 'Messenger',
'wechat' => 'WeChat',
'line' => 'Line',
];
@endphp
@foreach($socialLinks as $platform => $url)
@if(!empty($url) && isset($socialIcons[$platform]))
<a href="{{ $url }}" target="_blank" rel="noopener noreferrer" class="btn btn-sm btn-outline-secondary rounded-circle" style="width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center;" title="{{ $socialTitles[$platform] ?? ucfirst($platform) }}">
@if($platform === 'twitter')
<span style="font-weight: bold; font-size: 1.2rem;">{{ $socialIcons[$platform] }}</span>
@else
<i class="bi {{ $socialIcons[$platform] }}"></i>
@endif
</a>
@endif
@endforeach
</div>
@endif
</div>
</div>
</div>

View File

@ -45,10 +45,21 @@ Route::get('/email/verify', function () {
return view('auth.verify-email');
})->middleware('auth')->name('verification.notice');
Route::get('/email/verify/{id}/{hash}', function (Request $request) {
$request->user()->markEmailAsVerified();
return redirect('/')->with('verified', true);
})->middleware(['auth', 'signed'])->name('verification.verify');
Route::get('/email/verify/{id}/{hash}', function (Request $request, $id, $hash) {
$user = \App\Models\User::findOrFail($id);
if (! hash_equals((string) $hash, sha1($user->getEmailForVerification()))) {
abort(403, 'Invalid verification link.');
}
if ($user->hasVerifiedEmail()) {
return redirect('/login')->with('status', 'Email already verified.');
}
$user->markEmailAsVerified();
return redirect('/login')->with('status', 'Email verified successfully. You can now log in.');
})->middleware(['signed'])->name('verification.verify');
Route::post('/email/verification-notification', function (Request $request) {
$request->user()->sendEmailVerificationNotification();
@ -58,6 +69,9 @@ Route::post('/email/verification-notification', function (Request $request) {
// Family routes
Route::middleware(['auth', 'verified'])->group(function () {
Route::get('/profile', [FamilyController::class, 'profile'])->name('profile.show');
Route::get('/profile/edit', [FamilyController::class, 'editProfile'])->name('profile.edit');
Route::put('/profile', [FamilyController::class, 'updateProfile'])->name('profile.update');
Route::post('/profile/upload-picture', [FamilyController::class, 'uploadProfilePicture'])->name('profile.upload-picture');
Route::get('/family', [FamilyController::class, 'dashboard'])->name('family.dashboard');
Route::get('/family/create', [FamilyController::class, 'create'])->name('family.create');
Route::post('/family', [FamilyController::class, 'store'])->name('family.store');