Skip to content

Commit

Permalink
Merge pull request #84 from andes2912/Feature/improve-profile-karyawan
Browse files Browse the repository at this point in the history
Improve profile karyawan
  • Loading branch information
andes2912 authored Feb 4, 2022
2 parents 4ae3cc4 + 79dbf6b commit 20a6cd6
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 207 deletions.
50 changes: 15 additions & 35 deletions app/Http/Controllers/Karyawan/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ public function karyawanProfile($id)
return view('karyawan.profile.index', compact('user'));
}

// Profile Karyawan Cabang - Edit
public function karyawanProfileEdit(Request $request, $id)
{
$edit = User::find($id);
return view('karyawan.profile.edit', compact('edit'));
}

// Profile Karyawan Cabang - Save
public function karyawanProfileSave(Request $request, $id)
{
Expand All @@ -34,34 +27,21 @@ public function karyawanProfileSave(Request $request, $id)
$foto->storeAs($tujuan_upload,$nama_foto);
}

$edit = User::FindorFail($id);
$edit->id = $request->id;
$edit->name = $request->name;
$edit->email = $request->email;
$edit->alamat = $request->alamat;
$edit->no_telp = $request->no_telp;
$edit->nama_cabang = $request->nama_cabang;
$edit->alamat_cabang = $request->alamat_cabang;
$edit->foto = $nama_foto ?? Auth::user()->foto;
$edit->save();

alert()->success('Update Data Berhasil');
$id = $edit->id;
return redirect('profile-karyawan/' .$id.'');
if ($request->password) {
$password = Hash::make($request->password);
}
$profile = User::findOrFail($id);
$profile->name = $request->name;
$profile->email = $request->email;
$profile->alamat = $request->alamat;
$profile->nama_cabang = $request->nama_cabang;
$profile->alamat_cabang = $request->alamat_cabang;
$profile->foto = $nama_foto ?? Auth::user()->foto;
$profile->password = $password ?? Auth::user()->password;
$profile->save();

Session::flash('success','Data profile berhasil diupdate !');
return back();
}

// Change Password Karyawan
public function change_password(Request $request, $id)
{
$request->validate([
'password' => 'required|confirmed',
]);

$change_password = User::findOrFail($id);
$change_password->password = bcrypt($request->password);
$change_password->save();

Session::flash('success','Password Berhasil Diubah !');
return \redirect()->back();
}
}
88 changes: 0 additions & 88 deletions resources/views/karyawan/profile/edit.blade.php

This file was deleted.

172 changes: 144 additions & 28 deletions resources/views/karyawan/profile/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,61 +1,177 @@
@extends('layouts.backend')
@section('title','Profile')
@section('content')
@if($message = Session::get('success'))
@if ($message = Session::get('success'))
<div class="alert alert-success alert-block">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong>
</div>
@elseif($message = Session::get('error'))
<div class="alert alert-danger alert-block">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong>
</div>
@endif
<div class="row">
<div class="col-lg-4 col-xlg-3 col-md-5">
<div class="card">
<div class="card-body">
<div class="col text-center">
<div class="m-t-30"> <img src="{{asset($user->foto == null ? 'backend/images/profile/user.jpg' : 'storage/images/foto_profile/'. $user->foto )}}" class="rounded" width="230" />
<h4 class="card-title m-t-10">{{$user->name}}
</h4>
<h6 class="card-subtitle">Karyawan</h6>
<div class="m-t-30">
<img class="round" src="{{asset(Auth::user()->foto == null ? 'backend/images/profile/user.jpg' : 'storage/images/foto_profile/'. Auth::user()->foto )}}" alt="avatar" height="150" width="150">
<h4 class="card-title mt-1">{{Auth::user()->name}}</h4>
<h6 class="small">Customer</h6>
</div>
</div>
</div>
<div>
<hr>
</div>

<hr> </div>
<div class="card-body"> <small class="text-muted">Email address </small>
<h6>{{$user->email}}</h6> <small class="text-muted p-t-30 db">Phone</small>
<h6>{{$user->no_telp}}</h6> <small class="text-muted p-t-30 db">Address</small>
<h6>{{$user->alamat}}</h6>
<small class="text-muted p-t-30 db">Social Profile</small>
<br/>
<button class="btn btn-circle btn-secondary"><i class="fa fa-facebook"></i></button>
<button class="btn btn-circle btn-secondary"><i class="fa fa-twitter"></i></button>
<button class="btn btn-circle btn-secondary"><i class="fa fa-youtube"></i></button>

<div class="d-flex justify-content-between">
<a href="{{url('profile-karyawan/edit', Auth::user()->id)}}" class="btn btn-primary mt-2">Edit</a>
<a href="" data-toggle="modal" data-target="#change_password" class="btn btn-warning mt-2">Change Password</a>
</div>
<h6>{{Auth::user()->email}}</h6> <small class="text-muted p-t-30 db">Phone</small>
<h6>+{{Auth::user()->no_telp}}</h6> <small class="text-muted p-t-30 db">Address</small>
<h6>{{Auth::user()->alamat}}</h6>
<small class="text-muted p-t-30 db">Social Profile</small>
<br/>
<button class="btn btn-circle btn-secondary"><i class="fa fa-facebook"></i></button>
<button class="btn btn-circle btn-secondary"><i class="fa fa-twitter"></i></button>
<button class="btn btn-circle btn-secondary"><i class="fa fa-youtube"></i></button>
</div>

</div>
</div>

<div class="col-lg-8 col-xlg-9 col-md-7">
<div class="card">
<!-- Nav tabs -->
<ul class="nav nav-tabs profile-tab" role="tablist">
<li class="nav-item"> <a class="nav-link active" data-toggle="tab" href="#home" role="tab">Coming Soon</a> </li>
<li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#profile" role="tab">Coming Soon</a> </li>
<li class="nav-item"> <a class="nav-link" data-toggle="tab" href="#settings" role="tab">Coming Soon</a> </li>
<li class="nav-item"> <a class="nav-link active" data-toggle="tab" href="#home" role="tab">Informasi</a> </li>
</ul>

<div class="card-body">
<h5>COMING SOON !!!</h5>
<form action=" {{url('profile-karyawan/update', Auth::id())}}" method="POST" enctype="multipart/form-data">
@csrf
@method('PUT')
<div class="form-body">
<div class="row">
<div class="col-md-6">
<div class="form-group has-success">
<label class="control-label">Nama</label>
<input type="text" name="name" value=" {{Auth::user()->name}} " class="form-control @error('name') is-invalid @enderror">
@error('name')
<span class="invalid-feedback text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>

<div class="col-md-6">
<div class="form-group has-success">
<label class="control-label">Email</label>
<input type="text" name="email" value=" {{Auth::user()->email}} " class="form-control @error('email') is-invalid @enderror">
@error('email')
<span class="invalid-feedback text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>

<div class="col-md-12">
<div class="form-group has-success">
<label class="control-label">Alamat</label>
<textarea name="alamat" class="form-control" id="alamat" cols="5"> {{Auth::user()->alamat}} </textarea>
@error('alamat')
<span class="invalid-feedback text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>

<div class="col-md-6">
<div class="form-group has-success">
<label class="control-label">No WhatsApp</label>
<input type="text" name="number" class="form-control" value="{{Auth::user()->no_telp}}" />
@error('no_telp')
<span class="invalid-feedback text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>

<div class="col-md-6">
<div class="form-group has-success">
<label class="control-label">Foto</label>
<input type="file" name="foto" class="form-control @error('foto') is-invalid @enderror">
<span class="small text-warning">Biarkan kosong jika tidak ingin di update.</span>
@error('foto')
<span class="invalid-feedback text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>

<div class="col-md-6">
<div class="form-group has-success">
<label class="control-label">Password</label>
<input type="password" name="password" class="form-control @error('password') is-invalid @enderror">
<span class="small text-warning">Biarkan kosong jika tidak ingin di update.</span>
@error('password')
<span class="invalid-feedback text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>

<div class="col-md-6">
<div class="form-group has-success">
<label class="control-label">Konfirmasi Password</label>
<input type="password" name="password_confirmation" class="form-control @error('password_confirmation') is-invalid @enderror">
<span class="small text-warning">Biarkan kosong jika tidak ingin di update.</span>
@error('password_confirmation')
<span class="invalid-feedback text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
</div>
<h5>Data Laundry</h5>
<hr>

<div class="row">
<div class="col-md-12">
<div class="form-group has-success">
<label class="control-label">Nama Laundry (cabang))</label>
<input type="text" name="nama_cabang" class="form-control" value="{{Auth::user()->nama_cabang}}" />
@error('nama_cabang')
<span class="invalid-feedback text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>

<div class="col-md-12">
<div class="form-group has-success">
<label class="control-label">Alamat Laundry (cabang)</label>
<textarea name="alamat_cabang" class="form-control" id="alamat_cabang" cols="5"> {{Auth::user()->alamat_cabang}} </textarea>
@error('alamat_cabang')
<span class="invalid-feedback text-danger" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Update</button>
<a href="/home" class="btn btn-info">Batal</a>
</form>
</div>
</div>
</div>
</div>
@include('karyawan.profile.modal')
@endsection
Loading

0 comments on commit 20a6cd6

Please sign in to comment.