-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
196 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/Http/Controllers/Backend/User/ChangePasswordController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Backend\User; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Hash; | ||
|
||
class ChangePasswordController extends Controller | ||
{ | ||
public function view() | ||
{ | ||
return view('backend.user.changepassword'); | ||
} | ||
|
||
public function update(Request $request) | ||
{ | ||
if (!(Hash::check($request->get('current-password'), Auth::user()->password))) { | ||
// The passwords matches | ||
return redirect()->back()->with('error', 'Your current password does not matches with the password you provided. Please try again.'); | ||
} | ||
|
||
if (strcmp($request->get('current-password'), $request->get('new-password')) == 0) { | ||
//Current password and new password are same | ||
return redirect()->back()->with('error', 'New Password cannot be same as your current password. Please choose a different password.'); | ||
} | ||
|
||
$validatedData = $request->validate([ | ||
'current-password' => 'required', | ||
'new-password' => 'required|string|min:6|confirmed', | ||
]); | ||
|
||
//Change Password | ||
$user = Auth::user(); | ||
$user->password = Hash::make($request->get('new-password')); | ||
$user->save(); | ||
|
||
return redirect()->back()->with('success', 'Password changed successfully !'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Backend\User; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\User; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Auth; | ||
|
||
class ProfileController extends Controller | ||
{ | ||
public function view() | ||
{ | ||
$user = User::find(Auth::id()); | ||
|
||
return view('backend.user.profile', [ | ||
'name' => $user->name, | ||
'email' => $user->email, | ||
]); | ||
} | ||
|
||
public function update(Request $request) | ||
{ | ||
$user = User::find(Auth::id()); | ||
|
||
$user->email = $request->get('email'); | ||
|
||
$user->save(); | ||
|
||
return redirect()->back()->with('success', 'Profile updated.');; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
@extends('layouts.backend') | ||
|
||
@section('content') | ||
@if (session('error')) | ||
<div class="alert alert-danger"> | ||
{{ session('error') }} | ||
</div> | ||
@endif | ||
|
||
@if (session('success')) | ||
<div class="alert alert-success"> | ||
{{ session('success') }} | ||
</div> | ||
@endif | ||
|
||
<div class="row"> | ||
<div class="col-xl-6"> | ||
{{ html()->form('POST', route('updateProfile'))->class('form-horizontal')->open() }} | ||
<div class="card"> | ||
<div class="card-body"> | ||
<div class="row"> | ||
<div class="col-sm-6"> | ||
<h4 class="card-title mb-0"> | ||
Profile | ||
<small class="text-muted">Edit</small> | ||
</h4> | ||
</div><!--col--> | ||
</div><!--row--> | ||
|
||
<hr /> | ||
|
||
<div class="row mt-4 mb-4"> | ||
<div class="col"> | ||
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }} row"> | ||
<label for="name" class="col-sm-3 col-form-label">Name</label> | ||
|
||
<div class="col"> | ||
@role('admin') | ||
<input value="{{$name}}" id="name" type="text" class="form-control" name="name"> | ||
@else | ||
<input value="{{$name}}" id="name" type="text" class="form-control" name="name" disabled> | ||
@endrole | ||
|
||
@if ($errors->has('name')) | ||
<span class="help-block"> | ||
<strong>{{ $errors->first('name') }}</strong> | ||
</span> | ||
@endif | ||
</div> | ||
</div> | ||
|
||
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }} row"> | ||
<label for="email" class="col-sm-3 col-form-label">E-mail Address</label> | ||
|
||
<div class="col"> | ||
<input value="{{$email}}" id="email" type="email" class="form-control" name="email"> | ||
|
||
@if ($errors->has('email')) | ||
<span class="help-block"> | ||
<strong>{{ $errors->first('email') }}</strong> | ||
</span> | ||
@endif | ||
</div> | ||
</div> | ||
</div><!--col--> | ||
</div><!--row--> | ||
</div><!--card-body--> | ||
|
||
<div class="card-footer"> | ||
<div class="row"> | ||
<div class="col text-right"> | ||
<button type="submit" class="btn btn-primary"> | ||
Save | ||
</button> | ||
</div><!--row--> | ||
</div><!--row--> | ||
</div><!--card-footer--> | ||
</div><!--card--> | ||
{{ html()->form()->close() }} | ||
</div> | ||
</div> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters