Skip to content

Commit

Permalink
Merge pull request #26 from Yunnie-pin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Yunnie-pin committed Jul 9, 2023
2 parents fe614f9 + 6e66e2f commit a5524f4
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 42 deletions.
68 changes: 31 additions & 37 deletions app/Http/Controllers/ProfileUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;

class ProfileUserController extends Controller
{
Expand All @@ -13,54 +14,47 @@ class ProfileUserController extends Controller
public function index()
{
//
return view('profile');

}

/**
* Show the form for creating a new resource.
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
public function update(Request $request)
{
//
$request->validate([
'nama_lengkap' => 'required',
'no_telp' => 'required',
]);

if(!Hash::check($request->password, auth()->user()->password)){
return redirect('/dashboard')->with('error', 'Profile gagal diperbaharui, Password Salah');
}

User::where('id', auth()->user()->id)
->update([
'nama_lengkap' => $request->nama_lengkap,
'no_telp' => $request->no_telp
]);

return redirect('/dashboard')->with('success', 'Profile telah berhasil diubah');
}

/**
* Display the specified resource.
*/
public function show(User $user)
{
//
public function changePassword(){
return view('changepassword');
}

/**
* Show the form for editing the specified resource.
*/
public function edit(User $user)
{
//
}
public function updatePassword(Request $request){
$request->validate([
'password' => 'required|min:8|max:30',
'password_confirmation' => 'required|same:password'
]);

/**
* Update the specified resource in storage.
*/
public function update(Request $request, User $user)
{
//
}
User::where('id', auth()->user()->id)
->update([
'password' => Hash::make($request->password)
]);

/**
* Remove the specified resource from storage.
*/
public function destroy(User $user)
{
//
return redirect('/dashboard')->with('success', 'Password telah berhasil diubah');
}
}
79 changes: 79 additions & 0 deletions resources/views/changepassword.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
@extends('layouts.main')
@section('container')
<div class="pagetitle">
<h1>Change Password</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Profile</a></li>
<li class="breadcrumb-item active">Profile</li>
</ol>
</nav>
</div><!-- End Page Title -->

<section class="section dashboard">
<div class="row">

<!-- Left side columns -->
<div class="col-lg-12">
<div class="row">
<div class="card">
<div class="card-body p-3">

<form class="row g-3" method="post" action="{{route('update-password') }}">
@csrf
<div class="col-md-4">
<div class="pb-2">
<label for="nama" class="form-label">Email</label>
<input type="text" value="{{ auth()->user()->email }}" class="form-control"
disabled>
</div>

<div class="pb-2">
<label for="nama" class="form-label">Pasword Baru</label>
<input type="password" name="password" id="password"
class="form-control
@error('password')
is-invalid
@enderror
">

@error('password_confirmation')
<label class="form-check-label invalid-feedback">
{{ $message }}
</label>
@enderror
</div>

<div class="pb-2">
<label for="nama" class="form-label">Konfirmasi Password Baru</label>
<input type="password" name="password_confirmation" id="password_confirmation"
class="form-control
@error('password_confirmation')
is-invalid
@enderror
">

@error('password_confirmation')
<label class="form-check-label invalid-feedback">
{{ $message }}
</label>
@enderror
</div>

</div>

<div class="col-12 py-2">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>

<!-- end card -->
</div>
</div>
</div>
</div><!-- End Left side columns -->

</div>
</section>

@endsection
4 changes: 2 additions & 2 deletions resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
<div class="row">
<div class="card">
@if (session()->has('success'))
<div class="alert alert-success p-1" role="alert">
<div class="alert alert-success p-2" role="alert">
{{ session('success') }}
</div>
@endif

@if (session()->has('error'))
<div class="alert alert-danger p-1" role="alert">
<div class="alert alert-danger p-2" role="alert">
{{ session('error') }}
</div>
@endif
Expand Down
11 changes: 10 additions & 1 deletion resources/views/partials/navbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,23 @@
<hr class="dropdown-divider">
</li>
<li>
<a class="dropdown-item d-flex align-items-center" href="users-profile.html">
<a class="dropdown-item d-flex align-items-center" href="{{ route('profile') }}">
<i class="bi bi-gear"></i>
<span>Settings Profile</span>
</a>
</li> --}}
<li>
<hr class="dropdown-divider">
</li>
<li>
<a class="dropdown-item d-flex align-items-center" href="{{ route('change-password') }}">
<i class="bi bi-gear"></i>
<span>Ubah Password</span>
</a>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li>
<form action="{{ route('logout') }}" method="POST">
@csrf
Expand Down
146 changes: 146 additions & 0 deletions resources/views/profile.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
@extends('layouts.main')
@section('container')
<div class="pagetitle">
<h1>Perbaharui data pengguna</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Profile</a></li>
<li class="breadcrumb-item active">Perbaharui data pengguna</li>
</ol>
</nav>
</div><!-- End Page Title -->

<section class="section dashboard">
<div class="row">

<!-- Left side columns -->
<div class="col-lg-12">
<div class="row">
<div class="card">
<div class="card-body p-3">

<form class="row g-3" method="post" action="{{route('update-profile', ['profile' => auth()->user()->id]) }}">
@csrf
@method('put')
<div class="col-md-3">

<div class="py-2">
<label for="email" class="form-label">Email</label>
<input type="text" value="{{ auth()->user()->email }}" disabled
class="form-control"
id="email">

</div>

{{-- Username --}}
<div class="py-2">
<label for="username" class="form-label">Username</label>
<input type="text" value="{{ auth()->user()->username }}" disabled
class="form-control
@error('username')
is-invalid
@enderror
"
id="username">

@error('username')
<label class="form-check-label invalid-feedback">
{{ $message }}
</label>
@enderror
</div>



{{-- end email --}}
{{-- nama lengkap --}}

<div class="py-2">
<label for="nama_lengkap" class="form-label">Nama Lengkap</label>
<input type="text" value="{{ auth()->user()->nama_lengkap }}"
class="form-control
@error('nama_lengkap')
is-invalid
@enderror
"
id="nama_lengkap" name="nama_lengkap">


@error('nama_lengkap')
<label class="form-check-label invalid-feedback">
{{ $message }}
</label>
@enderror

</div>


{{-- end nama lengkap --}}
{{-- no telp --}}

<div class="py-2">
<label for="no_telp" class="form-label">Nomer Telp</label>
<input type="number" value="{{ auth()->user()->no_telp }}"
class="form-control
@error('no_telp')
is-invalid
@enderror
"
id="no_telp" name="no_telp">


@error('no_telp')
<label class="form-check-label invalid-feedback">
{{ $message }}
</label>
@enderror

</div>


{{-- end no telp --}}


</div>
<div class="col-md-3">

{{-- password --}}

<div class="py-2">
<label for="no_telp" class="form-label">Konfirmasi Password</label>
<input type="password"
class="form-control
@error('password')
is-invalid
@enderror
"
id="password" name="password" >
@error('password')
<label class="form-check-label invalid-feedback">
{{ $message }}
</label>
@enderror

</div>


{{-- end no telp --}}


</div>


<div class="col-12">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>

<!-- end card -->
</div>
</div>
</div>
</div><!-- End Left side columns -->

</div>
</section>
@endsection
2 changes: 0 additions & 2 deletions resources/views/rolesviews/administrasi/listpasien.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@
</div>
</form>
</div>



<!-- card -->
<div class="row p-3 border border-primary ">
<table id="myTable" class="table table-striped border-primary table-hover table-bordered">
Expand Down
3 changes: 3 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
'update' => 'update-profile'
])->except(['create', 'destroy', 'edit', 'store']) ->middleware('auth');

Route::get('/change-password', [ProfileUserController::class, 'changePassword'])->name('change-password')->middleware('auth');
Route::post('/change-password', [ProfileUserController::class, 'updatePassword'])->name('update-password')->middleware('auth');

Route::resource('/list-bidang', ListBidangController::class)->names([
'index' => 'list-bidang',
'create' => 'create-bidang',
Expand Down

0 comments on commit a5524f4

Please sign in to comment.