Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
partially create dashboard and payment details
Browse files Browse the repository at this point in the history
  • Loading branch information
FemiNoviaLina committed May 16, 2022
1 parent 0ac880c commit 9bbc90f
Show file tree
Hide file tree
Showing 27 changed files with 641 additions and 39 deletions.
48 changes: 45 additions & 3 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,62 @@

use Illuminate\Http\Request;

use App\Models\Order;
use App\Models\Vehicle;

class AdminController extends Controller
{
public function getCustomersDashboard()
{
return view('dashboard.customers');
}

public function getVehiclesDashboard()
public function getVehiclesDashboardCar()
{
$vehicles = Vehicle::where('type', '=', 'car')
->take(10)
->get();
return view('dashboard.vehicles', ['type' => 'Car', 'vehicles' => $vehicles]);
}

public function getVehiclesDashboardMotor()
{
return view('dashboard.vehicles');
$vehicles = Vehicle::where('type', '=', 'motor')
->take(10)
->get();
return view('dashboard.vehicles', ['type' => 'Motorcycles', 'vehicles' => $vehicles]);
}

public function getOrdersDashboard()
{
return view('dashboard.orders');
$selected = request()->input('selected') ? request()->input('selected') : 'All order';
$take = request()->input('take') ? request()->input('take') : 10;

$orders = Order::join('users', 'orders.user_id', '=', 'users.id')
->join('vehicles', 'orders.vehicle_id', '=', 'vehicles.id')
->select('orders.id', 'orders.pickup_date', 'orders.pickup_time',
'orders.dropoff_date', 'orders.dropoff_time', 'orders.order_status', 'orders.total_price',
'users.id as user_id', 'users.name as user_name', 'users.email',
'vehicles.name as vehicle_name', 'vehicles.id as vehicle_id')
->take($take)
->get();

return view('dashboard.orders', ['selected' => $selected, 'orders' => $orders]);
}

public function acceptOrder($id) {
$order = Order::find($id);
$order->order_status = 'WAITING_FOR_PAYMENT';
$order->save();

return redirect()->route('orders-dashboard');
}

public function rejectOrder($id) {
$order = Order::find($id);
$order->order_status = 'REJECTED';
$order->save();

return redirect()->route('orders-dashboard');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function store(LoginRequest $request)
$user = Auth::user();

if($user->hasRole('admin')) {
return redirect(route('admin_dashboard'));
return redirect(route('orders-dashboard'));
}

return redirect()->back()->withInput();
Expand Down
8 changes: 8 additions & 0 deletions app/Http/Controllers/RentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,12 @@ public function getUserOrders()

return view('order-history', ['orders' => $orders]);
}

public function getPaymentDetails($id)
{
$method = request()->input('method') ? request()->input('method') : 'BCA Transfer';
$order = Order::find($id);

return view('payment-details', ['order' => $order, 'selected_method' => $method]);
}
}
1 change: 1 addition & 0 deletions app/Http/Middleware/AdminAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AdminAuthenticated
{
Expand Down
1 change: 1 addition & 0 deletions app/Http/Middleware/UserAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class UserAuthenticated
{
Expand Down
4 changes: 4 additions & 0 deletions app/View/Components/Navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public function isRent($option) {
return $option == 'Rent';
}

public function isProduct($option) {
return $option == 'Product';
}

public function isSelected ($option) {
return $option == $this->selected;
}
Expand Down
Loading

0 comments on commit 9bbc90f

Please sign in to comment.