updated profile setting page
Cette révision appartient à :
Parent
914f4ceb36
révision
addbb796bd
@ -57,4 +57,27 @@ public function setSession($student)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// ProfileController.php
|
||||
public function changeImage(Request $request)
|
||||
{
|
||||
try {
|
||||
$user = Student::find(currentUserId());
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$imageName = rand(111, 999) . time() . '.' . $request->image->extension();
|
||||
$request->image->move(public_path('uploads/students'), $imageName);
|
||||
$user->image = $imageName;
|
||||
$user->save();
|
||||
|
||||
return redirect()->back()->with('success', 'Image changed successfully.');
|
||||
} else {
|
||||
return redirect()->back()->with('error', 'Please select a valid image file.');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// dd($e);
|
||||
return redirect()->back()->with('error', 'An error occurred. Please try again.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BIN
public/uploads/students/8841702108048.jpg
Fichier normal
BIN
public/uploads/students/8841702108048.jpg
Fichier normal
Fichier binaire non affiché.
|
Après Largeur: | Hauteur: | Taille: 70 KiB |
@ -926,13 +926,15 @@ class="purchase-area-items-start mb-0 d-flex align-items-lg-center flex-column f
|
||||
<div class="white-bg">
|
||||
<div class="change-image-wizard">
|
||||
<div class="image mx-auto">
|
||||
<img src="{{asset('public/frontend/dist/images/user/user-img-01.jpg')}}"
|
||||
alt="User" />
|
||||
<img src="{{ asset('public/uploads/students/' . $student_info->image) }}" alt="User" height="200" width="200">
|
||||
</div>
|
||||
<form action="#">
|
||||
<form id="changeImageForm" action="{{ route('change_image') }}" method="post"
|
||||
enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="submit" class="button button--primary-outline">CHANGE
|
||||
iMAGE</button>
|
||||
<input type="file" name="image" id="newImageInput">
|
||||
<button type="button" id="changeImageButton"
|
||||
class="button button--primary-outline">CHANGE IMAGE</button>
|
||||
</div>
|
||||
</form>
|
||||
<p>Image size should be under 1MB image ratio 200px.</p>
|
||||
@ -948,4 +950,24 @@ class="purchase-area-items-start mb-0 d-flex align-items-lg-center flex-column f
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@endsection
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Hide the file input initially
|
||||
$('#newImageInput').hide();
|
||||
|
||||
// Trigger the file input when the button is clicked
|
||||
$('#changeImageButton').click(function() {
|
||||
$('#newImageInput').click();
|
||||
});
|
||||
|
||||
// Automatically submit the form when a file is selected
|
||||
$('#newImageInput').change(function() {
|
||||
$('#changeImageForm').submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@ -42,7 +42,7 @@
|
||||
Route::get('/login', [auth::class, 'signInForm'])->name('login');
|
||||
Route::post('/login', [auth::class, 'signInCheck'])->name('login.check');
|
||||
Route::get('/logout', [auth::class, 'signOut'])->name('logOut');
|
||||
|
||||
|
||||
|
||||
Route::middleware(['checkauth'])->prefix('admin')->group(function () {
|
||||
Route::get('/dashboard', [dashboard::class, 'index'])->name('dashboard');
|
||||
@ -80,6 +80,8 @@
|
||||
Route::get('/dashboard', [studashboard::class, 'index'])->name('studentdashboard');
|
||||
Route::get('/profile', [stu_profile::class, 'index'])->name('student_profile');
|
||||
Route::post('/profile/save', [stu_profile::class, 'save_profile'])->name('student_save_profile');
|
||||
Route::post('/change-image', [stu_profile::class, 'changeImage'])->name('change_image');
|
||||
|
||||
|
||||
Route::get('/watchCourse', function () {
|
||||
return view('frontend.watchCourse');
|
||||
@ -137,4 +139,3 @@
|
||||
Route::get('add-to-cart/{id}', [CartController::class, 'addToCart'])->name('add.to.cart');
|
||||
Route::patch('update-cart', [CartController::class, 'update'])->name('update.cart');
|
||||
Route::delete('remove-from-cart', [CartController::class, 'remove'])->name('remove.from.cart');
|
||||
|
||||
|
||||
Chargement…
Référencer dans un nouveau ticket
Block a user