melengkapi usecase untuk setiap aktor

parent 86710ee0
......@@ -45,7 +45,7 @@ return $book->stock;
->addColumn(['data' => 'title', 'name'=>'title', 'title'=>'Jenis Makanan'])
->addColumn(['data' => 'stock', 'name'=>'amount', 'title'=>'Stock'])
->addColumn(['data' => 'harga', 'name'=>'harga', 'title'=>'harga'])
->addColumn(['data' => 'author.name', 'name'=>'author.name', 'title'=>'Pemesan'])
->addColumn(['data' => 'author.name', 'name'=>'author.name', 'title'=>'chef'])
->addColumn(['data' => 'action', 'name'=>'action', 'title'=>'Action', 'orderable'=>false, 'searchable'=>false]);
......
......@@ -29,7 +29,7 @@ $html = $htmlBuilder
->addColumn(['data' => 'title', 'name'=>'title', 'title'=>'Jenis Makanan'])
->addColumn(['data' => 'stock', 'name'=>'stock', 'title'=>'Stock', 'orderable'=>false, 'searchable'=>false])
->addColumn(['data' => 'harga', 'name'=>'harga', 'title'=>'harga'])
->addColumn(['data' => 'author.name', 'name'=>'author.name', 'title'=>'Pemesan'])
->addColumn(['data' => 'author.name', 'name'=>'author.name', 'title'=>'chef'])
->addColumn(['data' => 'action', 'name'=>'action', 'title'=>'', 'orderable'=>false, 'searchable'=>false]);
return view('guest.index')->with(compact('html'));
}
......
......@@ -38,7 +38,7 @@ class PesananController extends Controller
->addColumn(['data' => 'title', 'name'=>'title', 'title'=>'Jenis Makanan'])
->addColumn(['data' => 'stock', 'name'=>'amount', 'title'=>'Stock'])
->addColumn(['data' => 'harga', 'name'=>'harga', 'title'=>'harga'])
->addColumn(['data' => 'author.name', 'name'=>'author.name', 'title'=>'Pemesan'])
->addColumn(['data' => 'author.name', 'name'=>'author.name', 'title'=>'chef'])
->addColumn(['data' => 'action', 'name'=>'action', 'title'=>'Action', 'orderable'=>false, 'searchable'=>false]);
......@@ -132,9 +132,8 @@ class PesananController extends Controller
*/
public function edit($id)
{
$book = Book::find($id);
return view('books.edit')->with(compact('book'));
$author = Author::find($id);
return view('authors.edit')->with(compact('author'));
}
/**
......
......@@ -8,6 +8,9 @@ use App\Http\Requests\StorePegawaiRequest;
use App\Http\Requests\UpdatePegawaiRequest;
use Yajra\Datatables\Html\Builder;
use Yajra\Datatables\Datatables;
use App\Book;
use App\Author;
use App\session;
class pegawaiController extends Controller
{
......@@ -56,7 +59,7 @@ class pegawaiController extends Controller
*/
public function create()
{
return view('authors.create');
return view('authors._form_pegawai');
}
/**
......@@ -70,24 +73,24 @@ class pegawaiController extends Controller
$pegawai = pegawai::create($request->except('cover'));
// isi field cover jika ada cover yang diupload
if ($request->hasFile('cover')) {
// Mengambil file yang diupload
$uploaded_cover = $request->file('cover');
// mengambil extension file
$extension = $uploaded_cover->getClientOriginalExtension();
// membuat nama file random berikut extension
$filename = md5(time()) . '.' . $extension;
// menyimpan cover ke folder public/img
$destinationPath = public_path() . DIRECTORY_SEPARATOR . 'img';
$uploaded_cover->move($destinationPath, $filename);
// mengisi field cover di pegawai dengan filename yang baru dibuat
$pegawai->cover = $filename;
$pegawai->save();
}
Session::flash("flash_notification", [
"level"=>"success",
"message"=>"Berhasil menyimpan $pegawai->name"
]);
// if ($request->hasFile('cover')) {
//// Mengambil file yang diupload
// $uploaded_cover = $request->file('cover');
//// mengambil extension file
// $extension = $uploaded_cover->getClientOriginalExtension();
//// membuat nama file random berikut extension
// $filename = md5(time()) . '.' . $extension;
//// menyimpan cover ke folder public/img
// $destinationPath = public_path() . DIRECTORY_SEPARATOR . 'img';
// $uploaded_cover->move($destinationPath, $filename);
//// mengisi field cover di pegawai dengan filename yang baru dibuat
// $pegawai->cover = $filename;
// $pegawai->save();
// }
// Session::flash("flash_notification", [
// "level"=>"success",
// "message"=>"Berhasil menyimpan $pegawai->name"
// ]);
return redirect()->route('pegawai.index');
}
/**
......@@ -109,7 +112,8 @@ class pegawaiController extends Controller
*/
public function edit($id)
{
//
$author = Author::find($id);
return view('authors.create')->with(compact('author'));
}
/**
......@@ -132,6 +136,13 @@ class pegawaiController extends Controller
*/
public function destroy($id)
{
//
if(!Author::destroy($id)) return redirect()->back();
Session::flash("flash_notification", [
"level"=>"success",
"message"=>"Berhasil dihapus"
]);
return redirect()->route('authors.index');
}
}
@extends('layouts.app')
@section('content')
<section id="main-content">
<section class="wrapper">
<div class="container">
<div class="row">
<br>
<div class="col-md-10">
<ul class="breadcrumb">
<li><a href="{{ url('/home') }}">Dashboard</a></li>
<li><a href="{{ url('/admin/authors') }}">Pelanggan</a></li>
<li class="active">Ubah Pelanggan</li>
</ul>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">Ubah Pelanggan</h2>
</div>
<div class="panel-body">
{!! Form::model($author, ['url' => route('authors.update', $author->id),
'method'=>'put', 'class'=>'form-horizontal']) !!}
@include('authors.create_data_pegawai')
{!! Form::close() !!}
</div>
</div>
</div>
</div>
</div>
</section>
</section>
@endsection
......@@ -20,7 +20,7 @@
<div class="panel-body">
{!! Form::open(['url' => route('pegawai.store'),
'method' => 'post', 'enctype'=>'multipart/form-data','files'=>'true', 'class'=>'form-horizontal']) !!}
@include('books._form')
@include('authors.create_data_pegawai')
{!! Form::close() !!}
</div>
</div>
......
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
{!! Form::label('name', 'Nama', ['class'=>'col-md-2 control-label']) !!}
<div class="col-md-4">
{!! Form::text('name', null, ['class'=>'form-control']) !!}
{!! $errors->first('name', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group{{ $errors->has('alamat') ? ' has-error' : '' }}">
{!! Form::label('alamat', 'Alamat', ['class'=>'col-md-2 control-label']) !!}
<div class="col-md-4">
{!! Form::text('alamat', null, ['class'=>'form-control']) !!}
{!! $errors->first('alamat', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group{{ $errors->has('umur') ? ' has-error' : '' }}">
{!! Form::label('umur', 'Umur', ['class'=>'col-md-2 control-label']) !!}
<div class="col-md-4">
{!! Form::number('umur', null, ['class'=>'form-control', 'min'=>1]) !!}
{!! $errors->first('umur', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group{{ $errors->has('golongan') ? ' has-error' : '' }}">
{!! Form::label('golongan', 'Golongan', ['class'=>'col-md-2 control-label']) !!}
<div class="col-md-4">
{!! Form::text('golongan', null, ['class'=>'form-control']) !!}
{!! $errors->first('golongan', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group">
<div class="col-md-4 col-md-offset-2">
{!! Form::submit('Simpan', ['class'=>'btn btn-primary']) !!}
</div>
</div>
......@@ -29,17 +29,17 @@
</div>
<div class="form-group {!! $errors->has('author_id') ? 'has-error' : '' !!}">
{!! Form::label('author_id', 'pemesan', ['class'=>'col-md-2 control-label']) !!}
{!! Form::label('author_id', 'chef', ['class'=>'col-md-2 control-label']) !!}
<div class="col-md-4">
{!! Form::select('author_id', [''=>'']+App\Author::pluck('name','id')->all(), null, [
'class'=>'js-selectize',
'placeholder' => 'Pilih makanan']) !!}
'placeholder' => '']) !!}
{!! $errors->first('author_id', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group{{ $errors->has('cover') ? ' has-error' : '' }}">
{!! Form::label('cover', 'pembayaran', ['class'=>'col-md-2 control-label']) !!}
{!! Form::label('cover', 'gambar', ['class'=>'col-md-2 control-label']) !!}
<div class="col-md-4">
{!! Form::file('cover') !!}
@if (isset($book) && $book->cover)
......
......@@ -28,7 +28,7 @@
{!! Form::select('author_id[]', [''=>'']+App\Author::pluck('name','id')->all(), null, [
'class'=>'js-selectize',
'multiple',
'placeholder' => 'Pilih Penulis']) !!}
'placeholder' => 'Pilih Pemesan']) !!}
{!! $errors->first('author_id', '<p class="help-block">:message</p>') !!}
</div>
</div>
......
......@@ -88,7 +88,6 @@
@endif
@role('manager')
<li class="sub-menu">
<a href="javascript:;" >
<i class="fa fa-book"></i>
......@@ -133,7 +132,43 @@
<span>Data pesanan</span>
</a>
<ul class="sub">
<li><a href="{{ route('authors.index') }}">Pesanan</a></li>
<li><a href="{{ route('books.index') }}">Pesanan</a></li>
<li><a href="{{ route('pegawai.index') }}">Pembayaran</a></li>
<li><a href="{{ route('books.index') }}">laporan</a></li>
</ul>
</li>
{{--<li class="sub-menu">--}}
{{--<a href="javascript:;" >--}}
{{--<i class="fa fa-desktop"></i>--}}
{{--<span>pembayaran</span>--}}
{{--</a>--}}
{{--<ul class="sub">--}}
{{--<li><a href="{{ route('authors.index') }}">Pembayaran</a></li>--}}
{{--</ul>--}}
{{--</li>--}}
{{--<li class="sub-menu">--}}
{{--<a href="javascript:;" >--}}
{{--<i class="fa fa-book"></i>--}}
{{--<span>Laporan</span>--}}
{{--</a>--}}
{{--<ul class="sub">--}}
{{--<li><a href="{{ route('books.index') }}">laporan</a></li>--}}
{{--</ul>--}}
{{--</li>--}}
@endrole
@role('deliver')
<li class="sub-menu">
<a href="javascript:;" >
<i class="fa fa-book"></i>
<span>Data Pesanan</span>
</a>
<ul class="sub">
<li><a href="{{ route('books.index') }}">pesanan</a></li>
</ul>
</li>
......@@ -141,6 +176,18 @@
@endrole
@role('chef')
<li class="sub-menu">
<a href="javascript:;" >
<i class="fa fa-book"></i>
<span>Data Pesanan</span>
</a>
<ul class="sub">
<li><a href="{{ route('books.index') }}">Makanan</a></li>
</ul>
</li>
@endrole
</ul>
<!-- sidebar menu end-->
</div>
......
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