Skip to content

Commit

Permalink
menambahkan fitur edit profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunnie-pin committed Jul 9, 2023
1 parent 3a80a2f commit 03c44ee
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 48 deletions.
62 changes: 19 additions & 43 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,29 @@ 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)
{
//
}

/**
* Display the specified resource.
*/
public function show(User $user)
{
//
}

/**
* Show the form for editing the specified resource.
*/
public function edit(User $user)
{
//
}

/**
* Update the specified resource in storage.
*/
public function update(Request $request, User $user)
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy(User $user)
public function update(Request $request, $user)
{
//
$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');
}
}
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
2 changes: 1 addition & 1 deletion resources/views/partials/navbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<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>
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

0 comments on commit 03c44ee

Please sign in to comment.