Skip to content

Commit

Permalink
added changes
Browse files Browse the repository at this point in the history
  • Loading branch information
haziq-danial committed Jan 17, 2022
1 parent 32bfb1b commit 271a099
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_DATABASE=parking-ump
DB_USERNAME=root
DB_PASSWORD=

Expand Down
11 changes: 11 additions & 0 deletions app/Http/Controllers/BookingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ public function index()
return view('parking.index');
}

public function view()
{
$bookings = Booking::with('user', 'car')->get();
$count = 1;

return view('parking.view', [
'bookings' => $bookings,
'count' => $count
]);
}

public function book(Request $request)
{

Expand Down
2 changes: 2 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Spatie\Permission\Middlewares\PermissionMiddleware;
use Spatie\Permission\Middlewares\RoleMiddleware;

class Kernel extends HttpKernel
Expand Down Expand Up @@ -66,5 +67,6 @@ class Kernel extends HttpKernel
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,

'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class
];
}
2 changes: 2 additions & 0 deletions database/seeders/CreateRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function run()
Permission::create(['name' => 'create booking']);
Permission::create(['name' => 'edit booking']);
Permission::create(['name' => 'delete booking']);
Permission::create(['name' => 'view all booking']);

// manage user
Permission::create(['name' => 'manage user']);
Expand All @@ -42,6 +43,7 @@ public function run()
$admin->givePermissionTo('create booking');
$admin->givePermissionTo('edit booking');
$admin->givePermissionTo('delete booking');
$admin->givePermissionTo('view all booking');

$admin->givePermissionTo('manage user');
$admin->givePermissionTo('add user');
Expand Down
10 changes: 10 additions & 0 deletions resources/views/components/sidebar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@
<i class="right fas fa-angle-left"></i>
</p>
</a>
@can('view all booking')
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="{{ route('book-parking.view') }}" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>View all Parking</p>
</a>
</li>
</ul>
@endcan
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="{{ route('book-parking.index') }}" class="nav-link">
Expand Down
3 changes: 1 addition & 2 deletions resources/views/parking/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Current Booking</h1>
<h1>Booking Details</h1>
</div>

</div>
Expand All @@ -27,7 +27,6 @@
<div class="col-md-6">
<div class="card card-primary">
<div class="card-header">
<h3 class="card-title">Booking Details</h3>

<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
Expand Down
114 changes: 114 additions & 0 deletions resources/views/parking/view.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
@extends('layouts.app')

@section('stylesheet')
<!-- Google Font: Source Sans Pro -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
<link rel="stylesheet" href="{{ asset('dist/css/adminlte.min.css') }}">
<link rel="stylesheet" href="{{ asset('plugins/fontawesome-free/css/all.min.css ') }}">
<link rel="stylesheet" href="{{ asset('plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css') }}">
@endsection

@section('title', 'Previous Booking')

@section('content')
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Previous Booking</h1>
</div>

</div>
</div><!-- /.container-fluid -->
</section>

<section class="content">
<div class="card card-primary">
<div class="card-header">

<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
<i class="fas fa-minus"></i>
</button>
</div>
</div>
<div class="card-body">
<table class="table table-striped projects">
<thead>
<tr>
<th style="width: 1%">
#
</th>
<th style="width: 10%">
Date Booking
</th>
<th class="text-center" style="width: 1%">
Time Start
</th>
<th class="text-center" style="width: 1%">
Duration
</th>
<th class="text-center" style="width: 1%">
Parking slot
</th>
<th class="text-center" style="width: 1%">
Status
</th>
<th style="width: 2%" class="text-center">
Action
</th>
</tr>
</thead>
<tbody>
@foreach($bookings as $booking)
<tr>
<td>
{{ ++$count }}
</td>
<td>
{{ $booking->date_booking }}
</td>
<td class="text-center">
{{ $booking->start_time }}
</td>
<td class="text-center">
{{ $booking->parking_duration }}
</td>
<td class="text-center">
{{ $booking->parking_slot }}
</td>
<td class="text-center">
@include('components.booking-status-badge')
</td>
<td class="text-center">
<div class="btn-group">
<button type="button" class="btn btn-primary">Action</button>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-icon" data-toggle="dropdown">
<span class="sr-only">Toggle Dropdown</span>
</button>
<div class="dropdown-menu" role="menu">
<a class="dropdown-item" href="{{ route('book-parking.show', $booking->booking_id) }}">View</a>
<a href="{{ route('book-parking.delete', $booking->booking_id) }}" class="dropdown-item">Delete</a>
</div>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<!-- /.card -->
</section>
@endsection

@section('scripts')
<!-- jQuery -->
<script src="{{ asset('plugins/jquery/jquery.min.js') }}"></script>

<!-- Bootstrap 4 -->
<script src="{{ asset('plugins/bootstrap/js/bootstrap.bundle.min.js') }}"></script>

<!-- AdminLTE App -->
<script src="{{ asset('dist/js/adminlte.js') }}"></script>
@endsection
3 changes: 3 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
->name('previous');
Route::get('/show/{booking_id}', [BookingController::class, 'show'])
->name('show');
Route::get('/view', [BookingController::class, 'view'])
->middleware('permission:view all booking')
->name('view');

Route::post('/book', [BookingController::class, 'book'])
->name('book');
Expand Down

0 comments on commit 271a099

Please sign in to comment.