Commit b0271184 by PratiwiOkuli

CRUD Petugas oleh Admin

parent 05871c57
...@@ -12,4 +12,63 @@ class AdminController extends Controller ...@@ -12,4 +12,63 @@ class AdminController extends Controller
{ {
return view('adminlte::admin.listPetugas.index'); return view('adminlte::admin.listPetugas.index');
} }
public function createPetugas()
{
return view('adminlte::admin.listPetugas.create');
}
public function storePetugas(Request $request)
{
$this->validate($request, [
'name' => 'required',
'email' => 'required',
'username' => 'required',
'password' => 'required',
'status' => 'required',
]);
$users = new User();
$users->name = $request['name'];
$users->email = $request['email'];
$users->username =$request['username'];
$users->password =bcrypt($request['password']);
$users->status = $request['status'];
$users->save();
return redirect('listPetugas');
}
public function destroyPetugas($id)
{
$users = User::find($id);
$users->delete();
return redirect('listPetugas');
}
public function editPetugas($id)
{
$users = User::where('id', $id)->first();
return view('adminlte::admin.listPetugas.edit')->with('users', $users);
}
public function updatePetugas(Request $request, $id)
{
$this->validate($request, [
'name' => 'required',
'email' => 'required',
'username' => 'required',
'password' => 'required',
'status' => 'required',
]);
$users = User::findOrFail($id);
$users->name = $request->name;
$users->email = $request->email;
$users->username = $request->username;
$users->password = bcrypt($request->password);
$users->status = $request->status;
$users->save();
return redirect('listPetugas');
}
} }
\ No newline at end of file
...@@ -9,13 +9,31 @@ ...@@ -9,13 +9,31 @@
@endsection @endsection
@section('main-content') @section('main-content')
<div class="container-fluid spark-screen"> <table class="table table-striped">
<div class="row"> <thead>
<div class="col-md-8 col-md-offset-2"> <tr>
<div class="panel panel-default"> <th>Username/th>
</div> <th>Nama Barang</th>
</div> <th>Kategori</th>
</div> <th>Jumlah</th>
</div> <th>Total Harga</th>
<th>Status Pengantaran</th>
</tr>
</thead>
<tbody>
@foreach($transaksis as $transaksi)
<tr>
<td>{{$transaksi->username}}</td>
<td>{{$transaksi->nama_barang}}</td>
<td>{{$transaksi->kategori}}</td>
<td>{{$transaksi->jumlah}}</td>
<td>{{$transaksi->total_harga}}</td>
<td>
<a href="{{ url('/konfirmasi', $transaksi->id) }}" type="submit" button type="button" class="btn btn-warning">Konfirmasi</a>
</tr>
@endforeach
</tbody>
</table>
@endsection @endsection
@extends('adminlte::layouts.auth')
@extends('adminlte::layouts.app')
@section('htmlheader_title')
{{ trans('adminlte_lang::message.home') }}
@endsection
@section('contentheader_title')
<center>Register Petugas</center>
@section('main-content')
<body class="hold-transition register-page">
<div id="app">
<div class="register-box">
<!-- @if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> {{ trans('adminlte_lang::message.someproblems') }}<br><br>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
-->
<div class="register-box-body">
<p class="login-box-msg">{{ trans('adminlte_lang::message.registermember') }}</p>
<form action="{{ url('/storePetugas') }}" method="POST">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group has-feedback">
<input type="text" class="form-control" placeholder="{{ trans('adminlte_lang::message.fullname') }}" name="name" value="{{ old('name') }}"/>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="email" class="form-control" placeholder="{{ trans('adminlte_lang::message.email') }}" name="email" value="{{ old('email') }}"/>
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="text" class="form-control" placeholder="Username" name="username" value="{{ old('username') }}"/>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" placeholder="{{ trans('adminlte_lang::message.password') }}" name="password"/>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" class="form-control" placeholder="{{ trans('adminlte_lang::message.retrypepassword') }}" name="password_confirmation"/>
<span class="glyphicon glyphicon-log-in form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="int" class="form-control" placeholder="0" name="saldo" readonly/>
<span class="glyphicon glyphicon-log-in form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<select name="status" class="form-control">
<option value="kasir">Kasir</option>
<option value="inventori">Inventori</option>
</select>
</div>
<div class="row">
<div class="col-xs-1">
<label>
</label>
</div><!-- /.col -->
<div class="col-xs-6">
<div class="form-group">
</div>
</div><!-- /.col -->
<div class="col-xs-4 col-xs-push-1">
<button type="submit" class="btn btn-primary btn-block btn-flat">{{ trans('adminlte_lang::message.register') }}</button>
</div><!-- /.col -->
</div>
</form>
</div><!-- /.form-box -->
</div><!-- /.register-box -->
</div>
@include('adminlte::layouts.partials.scripts_auth')
@include('adminlte::auth.terms')
<script>
$(function () {
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' // optional
});
});
</script>
</body>
@endsection
@endsection
@extends('adminlte::layouts.app')
@section('htmlheader_title')
Edit
@endsection
@section('contentheader_title')
Page Edit Request
@endsection
@section('main-content')
<div class="container">
<div class="col-md-8 col-md-offset-2">
<div class="panel-body">
<form class="form-horizontal" action="{{ url('/updatePetugas', $users->id) }}" method="POST">
{!! csrf_field() !!}
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label">Nama</label>
<div class="col-md-6">
<input type="text" class="form-control" name="name" value="{{ $users->name}}" >
@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' : '' }}">
<label for="title" class="col-md-4 control-label">Email</label>
<div class="col-md-6">
<input type="text" class="form-control" name="email" value="{{ $users->email}}" >
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label">Username</label>
<div class="col-md-6">
<input type="text" class="form-control" name="username" value="{{ $users->username }}" >
@if ($errors->has('username'))
<span class="help-block">
<strong>{{ $errors->first('username') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label">Password</label>
<div class="col-md-6">
<input type="password" class="form-control" name="password" value="{{ $users->password }}" >
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group{{ $errors->has('status') ? ' has-error' : '' }}">
<label for="title" class="col-md-4 control-label" value="{{ $users->status }}">Status</label>
@if ($errors->has('status'))
<span class="help-block">
<strong>{{ $errors->first('status') }}</strong>
</span>
@endif
<div class="col-md-6">
<select name="status" class="form-control">
<option value="kasir">Kasir</option>
<option value="inventori">Inventori</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-primary">
Simpan
</button>
</div>
</div>
</form>
</div>
</div>
</div>
@endsection
\ No newline at end of file
...@@ -9,24 +9,30 @@ ...@@ -9,24 +9,30 @@
@endsection @endsection
@section('main-content') @section('main-content')
<div class="container-fluid spark-screen"> <table class="table table-striped">
<div class="row"> <thead>
<div class="col-md-8 col-md-offset-2"> <tr>
<div class="panel panel-default"> <th>Nama</th>
<!-- <div class="panel-heading">Home</div> <th>Email</th>
<div class="panel-body"> <th>Username</th>
<label style="font-weight:bolder;color:black;font-size: 17px">List Pegawai</label><br> <th>Status</th>
Merupakan halaman list pegawai UD Antoni. Admin dapat melihat daftar pegawai dan melakukan penghapusan dan penambahan pegawai baru. <th>Action</th>
<br><br> </tr>
</thead>
<label style="font-weight:bolder;color:black;font-size: 17px">Laporan Transaksi</label><br> <tbody>
Merupakan halaman list transaksi dari layanan admin. User dapat melihat daftar member cafe dan melakukan penghapusan terhadap member. @foreach($users as $user)
</li> <tr>
{{ trans('adminlte_lang::message.logged') }} <td>{{$user->username}}</td>
</div> --> <td>{{$user->email}}</td>
</div> <td>{{$user->username}}</td>
</div> <td>{{$user->status}}
</div> <td>
</div> <a href="{{ url('/editPetugas', $user->id) }}" type="submit" button type="button" class="btn btn-warning">Edit</a>
<a href="{{ url('/deletePetugas', $user->id) }}" type="submit" button type="button" class="btn btn-warning">Delete</a></td>
</tr>
@endforeach
</tbody>
</table>
<a href="{{ url('/createPetugas') }}" button type="button" class="btn btn-info">Create</a></button>
@endsection @endsection
...@@ -37,6 +37,12 @@ Route::group(['middleware' => ['web','auth']], function(){ ...@@ -37,6 +37,12 @@ Route::group(['middleware' => ['web','auth']], function(){
Route::group(['middleware' => ['web','auth','admin']], function () { Route::group(['middleware' => ['web','auth','admin']], function () {
Route::get('/laporanTransaksi', 'AdminController@laporanTransaksi'); Route::get('/laporanTransaksi', 'AdminController@laporanTransaksi');
Route::get('/listPetugas', 'AdminController@listPetugas'); Route::get('/listPetugas', 'AdminController@listPetugas');
Route::get('/listPetugas', 'AdminController@listPetugas');
Route::get('/createPetugas', 'AdminController@createPetugas');
Route::post('/storePetugas', 'AdminController@storePetugas');
Route::get('/editPetugas/{id}', 'AdminController@editPetugas');
Route::post('/updatePetugas/{id}', 'AdminController@updatePetugas');
Route::get('/deletePetugas/{id}', 'AdminController@destroyPetugas');
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment