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