melengkapi aktor manager sesuai usecase yang ada

parent e6d48c6a
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -17,7 +17,7 @@ class Author extends Model ...@@ -17,7 +17,7 @@ class Author extends Model
if ($author->books->count() > 0) { if ($author->books->count() > 0) {
$html = 'Makanan tidak bisa dipesan masih memiliki pesanan : '; $html = 'Makanan tidak dapat dipesan, masih memiliki pesanan : ';
$html .= '<ul>'; $html .= '<ul>';
foreach ($author->books as $book) { foreach ($author->books as $book) {
$html .= "<li>$book->title</li>"; $html .= "<li>$book->title</li>";
......
...@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Session; ...@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Session;
class Book extends Model class Book extends Model
{ {
protected $fillable = ['title', 'author_id', 'amount']; protected $fillable = ['title', 'author_id', 'amount', 'harga'];
public static function boot() public static function boot()
{ {
......
...@@ -25,7 +25,7 @@ class BooksController extends Controller ...@@ -25,7 +25,7 @@ class BooksController extends Controller
public function index(Request $request, Builder $htmlBuilder) public function index(Request $request, Builder $htmlBuilder)
{ {
if ($request->ajax()) { if ($request->ajax()) {
$books = Book::with('author');//Penggunaan method with() akan meload relasi dari Book ke Author dengan teknik eager loading $books = Book::with('author');
return Datatables::of($books) return Datatables::of($books)
->addColumn('stock', function($book){ ->addColumn('stock', function($book){
return $book->stock; return $book->stock;
...@@ -43,7 +43,8 @@ return $book->stock; ...@@ -43,7 +43,8 @@ return $book->stock;
$html = $htmlBuilder $html = $htmlBuilder
->addColumn(['data' => 'title', 'name'=>'title', 'title'=>'Jenis Makanan']) ->addColumn(['data' => 'title', 'name'=>'title', 'title'=>'Jenis Makanan'])
->addColumn(['data' => 'stock', 'name'=>'amount', 'title'=>'Stok']) ->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'=>'Pemesan'])
->addColumn(['data' => 'action', 'name'=>'action', 'title'=>'Action', 'orderable'=>false, 'searchable'=>false]); ->addColumn(['data' => 'action', 'name'=>'action', 'title'=>'Action', 'orderable'=>false, 'searchable'=>false]);
......
...@@ -21,14 +21,15 @@ return Datatables::of($books) ...@@ -21,14 +21,15 @@ return Datatables::of($books)
return $book->stock; return $book->stock;
}) })
->addColumn('action', function($book){ ->addColumn('action', function($book){
if (Laratrust::hasRole('admin')) return '';// jika admin tidak muncul tombol pinjam if (Laratrust::hasRole('admin')) return '';
return '<a class="btn btn-xs btn-primary" href="'.route('guest.books.borrow', $book->id).'">Pesan</a>'; return '<a class="btn btn-xs btn-primary" href="'.route('guest.books.borrow', $book->id).'">Pesan</a>';
})->make(true); })->make(true);
} }
$html = $htmlBuilder $html = $htmlBuilder
->addColumn(['data' => 'title', 'name'=>'title', 'title'=>'Jenis Makanan']) ->addColumn(['data' => 'title', 'name'=>'title', 'title'=>'Jenis Makanan'])
->addColumn(['data' => 'stock', 'name'=>'stock', 'title'=>'Jumlah Makanan', 'orderable'=>false, 'searchable'=>false]) ->addColumn(['data' => 'stock', 'name'=>'stock', 'title'=>'Stock', 'orderable'=>false, 'searchable'=>false])
->addColumn(['data' => 'author.name', 'name'=>'author.name', 'title'=>'Nama Pemesan']) ->addColumn(['data' => 'harga', 'name'=>'harga', 'title'=>'Harga'])
->addColumn(['data' => 'author.name', 'name'=>'author.name', 'title'=>'Pemesan'])
->addColumn(['data' => 'action', 'name'=>'action', 'title'=>'', 'orderable'=>false, 'searchable'=>false]); ->addColumn(['data' => 'action', 'name'=>'action', 'title'=>'', 'orderable'=>false, 'searchable'=>false]);
return view('guest.index')->with(compact('html')); return view('guest.index')->with(compact('html'));
} }
......
...@@ -19,6 +19,8 @@ class pegawaiController extends Controller ...@@ -19,6 +19,8 @@ class pegawaiController extends Controller
return view('dashboard.admin', ['data'=> $data]); return view('dashboard.admin', ['data'=> $data]);
} }
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* *
......
...@@ -28,6 +28,7 @@ class StoreBookRequest extends FormRequest ...@@ -28,6 +28,7 @@ class StoreBookRequest extends FormRequest
'title' => 'required|unique:books,title', 'title' => 'required|unique:books,title',
'author_id' => 'required|exists:authors,id', 'author_id' => 'required|exists:authors,id',
'amount' => 'numeric', 'amount' => 'numeric',
'amount' => 'harga',
'cover' => 'image|max:2048' 'cover' => 'image|max:2048'
]; ];
} }
......
...@@ -12,7 +12,7 @@ return [ ...@@ -12,7 +12,7 @@ return [
| any other location as required by the application or its packages. | any other location as required by the application or its packages.
*/ */
'name' => 'FoodBooking', 'name' => 'PizzaAndaliman',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
......
...@@ -56,8 +56,8 @@ return [ ...@@ -56,8 +56,8 @@ return [
*/ */
'from' => [ 'from' => [
'address' => 'admin@ultraperpus.com', 'address' => 'foodbooking@gmail.com',
'name' => 'Admin UltraPerpus', 'name' => 'PizzaAndaliman',
], ],
/* /*
......
...@@ -18,6 +18,7 @@ $table->increments('id'); ...@@ -18,6 +18,7 @@ $table->increments('id');
$table->string('title'); $table->string('title');
$table->integer('author_id')->unsigned(); $table->integer('author_id')->unsigned();
$table->integer('amount')->unsigned(); $table->integer('amount')->unsigned();
$table->integer('harga')->unsigned();
$table->string('cover')->nullable(); $table->string('cover')->nullable();
$table->timestamps(); $table->timestamps();
$table->foreign('author_id')->references('id')->on('authors') $table->foreign('author_id')->references('id')->on('authors')
......
...@@ -18,16 +18,16 @@ $memberRole->display_name = "Member"; ...@@ -18,16 +18,16 @@ $memberRole->display_name = "Member";
$memberRole->save(); $memberRole->save();
// Membuat sample admin // Membuat sample admin
$admin = new User(); $admin = new User();
$admin->name = 'Admin Ultraviolet'; $admin->name = 'Admin Pizza Andaliman';
$admin->email = 'ultraviolet@gmail.com'; $admin->email = 'admin@gmail.com';
$admin->password = bcrypt('verly123'); $admin->password = bcrypt('admin');
$admin->save(); $admin->save();
$admin->attachRole($adminRole); $admin->attachRole($adminRole);
// Membuat sample member // Membuat sample member
$member = new User(); $member = new User();
$member->name = "Sample Member"; $member->name = "Sample Member";
$member->email = 'member@gmail.com'; $member->email = 'nicolas@gmail.com';
$member->password = bcrypt('rahasia'); $member->password = bcrypt('nikolas');
$member->save(); $member->save();
$member->attachRole($memberRole); $member->attachRole($memberRole);
} }
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
<div class="col-md-10"> <div class="col-md-10">
<ul class="breadcrumb"> <ul class="breadcrumb">
<li><a href="{{ url('/home') }}">Dashboard</a></li> <li><a href="{{ url('/home') }}">Dashboard</a></li>
<li><a href="{{ url('/admin/authors') }}">Pelanggan</a></li> <li><a href="{{ url('/admin/authors') }}">pegawai</a></li>
<li class="active">Tambah Pelanggan</li> <li class="active">Tambah pegawai</li>
</ul> </ul>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Tambah Pelanggan</h2> <h2 class="panel-title">Tambah pegawai</h2>
</div> </div>
<div class="panel-body"> <div class="panel-body">
......
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
<div class="col-md-10"> <div class="col-md-10">
<ul class="breadcrumb"> <ul class="breadcrumb">
<li><a href="{{ url('/home') }}">PizzaAndaliman</a></li> <li><a href="{{ url('/home') }}">PizzaAndaliman</a></li>
<li class="active">Pelanggan</li> <li class="active">PizzaAndaliman</li>
</ul> </ul>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Pelanggan</h2> <h2 class="panel-title">PizzaAndaliman</h2>
</div> </div>
<div class="panel-body"> <div class="panel-body">
......
...@@ -6,27 +6,37 @@ ...@@ -6,27 +6,37 @@
</div> </div>
</div> </div>
<div class="form-group {!! $errors->has('author_id') ? 'has-error' : '' !!}">
{!! Form::label('author_id', 'id_makanan', ['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']) !!}
{!! $errors->first('author_id', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group{{ $errors->has('amount') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('amount') ? ' has-error' : '' }}">
{!! Form::label('amount', 'sisa makanan', ['class'=>'col-md-2 control-label']) !!} {!! Form::label('amount', 'stock', ['class'=>'col-md-2 control-label']) !!}
<div class="col-md-4"> <div class="col-md-4">
{!! Form::number('amount', null, ['class'=>'form-control', 'min'=>1]) !!} {!! Form::number('amount', null, ['class'=>'form-control', 'min'=>1]) !!}
{!! $errors->first('amount', '<p class="help-block">:message</p>') !!} {!! $errors->first('amount', '<p class="help-block">:message</p>') !!}
@if (isset($book)) @if (isset($book))
<p class="help-block">{{ $book->borrowed }} Makanan sedang dipesan</p> <p class="help-block">{{ $book->borrowed }} makanan sedang dipesan</p>
@endif @endif
</div> </div>
</div> </div>
<div class="form-group {!! $errors->has('harga') ? 'has-error' : '' !!}">
{!! Form::label('harga', 'Harga', ['class'=>'col-md-2 control-label']) !!}
<div class="col-md-4">
{!! Form::select('harga', [''=>'']+App\Author::pluck('name','id')->all(), null, [
'class'=>'js-selectize',
'placeholder' => 'harga']) !!}
{!! $errors->first('harga', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group {!! $errors->has('author_id') ? 'has-error' : '' !!}">
{!! Form::label('author_id', 'pemesan', ['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']) !!}
{!! $errors->first('author_id', '<p class="help-block">:message</p>') !!}
</div>
</div>
<div class="form-group{{ $errors->has('cover') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('cover') ? ' has-error' : '' }}">
{!! Form::label('cover', 'pembayaran', ['class'=>'col-md-2 control-label']) !!} {!! Form::label('cover', 'pembayaran', ['class'=>'col-md-2 control-label']) !!}
<div class="col-md-4"> <div class="col-md-4">
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
{!! Form::open(['url' => route('export.books.post'), {!! Form::open(['url' => route('export.books.post'),
'method' => 'post', 'class'=>'form-horizontal']) !!} 'method' => 'post', 'class'=>'form-horizontal']) !!}
<div class="form-group {!! $errors->has('author_id') ? 'has-error' : '' !!}"> <div class="form-group {!! $errors->has('author_id') ? 'has-error' : '' !!}">
{!! Form::label('author_id', 'Penulis', ['class'=>'col-md-2 control-label']) !!} {!! Form::label('author_id', 'Stock', ['class'=>'col-md-2 control-label']) !!}
<div class="col-md-4"> <div class="col-md-4">
{!! Form::select('author_id[]', [''=>'']+App\Author::pluck('name','id')->all(), null, [ {!! Form::select('author_id[]', [''=>'']+App\Author::pluck('name','id')->all(), null, [
'class'=>'js-selectize', 'class'=>'js-selectize',
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<div class="col-md-10"> <div class="col-md-10">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h2 class="panel-title">Daftar Makanan</h2> <h2 class="panel-title">List Makanan</h2>
</div> </div>
<div class="panel-body"> <div class="panel-body">
......
...@@ -87,29 +87,30 @@ ...@@ -87,29 +87,30 @@
</li> </li>
@endif @endif
@role('admin') @role('admin')
<li class="sub-menu"> <li class="sub-menu">
<a href="javascript:;" > <a href="javascript:;" >
<i class="fa fa-desktop"></i> <i class="fa fa-book"></i>
<span>Data Pelanggan</span> <span>Data Makanan</span>
</a> </a>
<ul class="sub"> <ul class="sub">
<li><a href="{{ route('authors.index') }}">Pelanggan</a></li> <li><a href="{{ route('books.index') }}">Makanan</a></li>
</ul> </ul>
</li> </li>
<li class="sub-menu"> <li class="sub-menu">
<a href="javascript:;" > <a href="javascript:;" >
<i class="fa fa-book"></i> <i class="fa fa-desktop"></i>
<span>Data Makanan</span> <span>Data Pelanggan</span>
</a> </a>
<ul class="sub"> <ul class="sub">
<li><a href="{{ route('books.index') }}">Makanan</a></li> <li><a href="{{ route('authors.index') }}">Pelanggan</a></li>
</ul> </ul>
</li> </li>
<li class="sub-menu"> <li class="sub-menu">
<a href="javascript:;" > <a href="javascript:;" >
<i class="fa fa-desktop"></i> <i class="fa fa-desktop"></i>
......
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>Data Foodbooking</title> <title>Data PizzaAndaliman</title>
<style> <style>
/* -------------------------------------------------------------- /* --------------------------------------------------------------
...@@ -70,7 +70,7 @@ img,tr {page-break-inside: avoid;} ...@@ -70,7 +70,7 @@ img,tr {page-break-inside: avoid;}
</style> </style>
</head> </head>
<body> <body>
<h1>Data foodbooking</h1> <h1>PizzaAndaliman</h1>
<hr> <hr>
<table> <table>
<thead> <thead>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">Halo</div> <div class="panel-heading">Halo</div>
<div class="panel-body"> <div class="panel-body">
Selamat datang di Menu PizzaAndaliman! Selamat datang, Sistem Informasi PizzaAndaliman siap melayani Anda!
</div> </div>
</div> </div>
</div> </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