Skip to content

Commit 26e5e32

Browse files
committed
Integration Landing page, Checkout, Dashboard
1 parent 38329c4 commit 26e5e32

File tree

9 files changed

+248
-31
lines changed

9 files changed

+248
-31
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
use App\Models\Checkout;
7+
use Auth;
8+
9+
class HomeController extends Controller
10+
{
11+
public function dashboard()
12+
{
13+
$checkouts = Checkout::with('Camp')->whereUserId(Auth::id())->get();
14+
return view('user.dashboard', [
15+
'checkouts' => $checkouts
16+
]);
17+
}
18+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\User;
4+
5+
use App\Models\Camp;
6+
use App\Models\Checkout;
7+
use Illuminate\Http\Request;
8+
use App\Http\Controllers\Controller;
9+
use Auth;
10+
11+
class CheckoutController extends Controller
12+
{
13+
/**
14+
* Display a listing of the resource.
15+
*
16+
* @return \Illuminate\Http\Response
17+
*/
18+
public function index()
19+
{
20+
//
21+
}
22+
23+
/**
24+
* Show the form for creating a new resource.
25+
*
26+
* @return \Illuminate\Http\Response
27+
*/
28+
public function create(Camp $camp)
29+
{
30+
return view('checkout.create',[
31+
'camp' => $camp
32+
]);
33+
}
34+
35+
/**
36+
* Store a newly created resource in storage.
37+
*
38+
* @param \Illuminate\Http\Request $request
39+
* @return \Illuminate\Http\Response
40+
*/
41+
public function store(Request $request, Camp $camp)
42+
{
43+
// mapping request data
44+
$data = $request->all();
45+
$data['user_id'] = Auth::id();
46+
$data['camp_id'] = $camp->id;
47+
48+
// Update user data
49+
$user = Auth::user();
50+
$user->email = $data['email'];
51+
$user->name = $data['name'];
52+
$user->occupation = $data['occupation'];
53+
$user->save();
54+
55+
// create checkout
56+
$checkout = Checkout::create($data);
57+
58+
return redirect(route('checkout.success'));
59+
}
60+
61+
/**
62+
* Display the specified resource.
63+
*
64+
* @param \App\Models\Checkout $checkout
65+
* @return \Illuminate\Http\Response
66+
*/
67+
public function show(Checkout $checkout)
68+
{
69+
//
70+
}
71+
72+
/**
73+
* Show the form for editing the specified resource.
74+
*
75+
* @param \App\Models\Checkout $checkout
76+
* @return \Illuminate\Http\Response
77+
*/
78+
public function edit(Checkout $checkout)
79+
{
80+
//
81+
}
82+
83+
/**
84+
* Update the specified resource in storage.
85+
*
86+
* @param \Illuminate\Http\Request $request
87+
* @param \App\Models\Checkout $checkout
88+
* @return \Illuminate\Http\Response
89+
*/
90+
public function update(Request $request, Checkout $checkout)
91+
{
92+
//
93+
}
94+
95+
/**
96+
* Remove the specified resource from storage.
97+
*
98+
* @param \App\Models\Checkout $checkout
99+
* @return \Illuminate\Http\Response
100+
*/
101+
public function destroy(Checkout $checkout)
102+
{
103+
//
104+
}
105+
106+
/**
107+
* Remove the specified resource from storage.
108+
*
109+
* @param \App\Models\Checkout $checkout
110+
* @return \Illuminate\Http\Response
111+
*/
112+
public function success(Checkout $checkout)
113+
{
114+
return view('checkout.success');
115+
}
116+
}

app/Models/Checkout.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Eloquent\Factories\HasFactory;
66
use Illuminate\Database\Eloquent\Model;
77
use Illuminate\Database\Eloquent\SoftDeletes;
8+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
89

910
class Checkout extends Model
1011
{
@@ -14,7 +15,23 @@ class Checkout extends Model
1415
'user_id',
1516
'camp_id',
1617
'card_number',
18+
'expired',
1719
'cvc',
1820
'is_paid'
1921
];
22+
23+
public function setExpiredAttribute($value)
24+
{
25+
$this->attributes['expired'] =date('Y-m-t', strtotime($value));
26+
}
27+
28+
/**
29+
* Get the Camp that owns the Checkout
30+
*
31+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
32+
*/
33+
public function Camp(): BelongsTo
34+
{
35+
return $this->belongsTo(Camp::class);
36+
}
2037
}

resources/views/checkout.blade.php renamed to resources/views/checkout/create.blade.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<div class="col-lg-5 col-12">
2525
<div class="item-bootcamp">
2626
<img src="{{asset('assets/item_bootcamp.png')}}" alt="" class="cover">
27-
<h1 class="package">
28-
HYPE!!
27+
<h1 class="package text-uppercase">
28+
{{$camp->title}}
2929
</h1>
3030
<p class="description">
3131
Take the next step and invest in your future success. Fill out the secure payment form now to enroll in CourseCast top-notch online courses.
@@ -34,32 +34,33 @@
3434
</div>
3535
<div class="col-lg-1 col-12"></div>
3636
<div class="col-lg-6 col-12">
37-
<form action="{{route('checkout.success')}}" class="basic-form">
37+
<form action="{{route('checkout.store', $camp->id)}}" class="basic-form" method="POST">
38+
@csrf
3839
<div class="mb-4">
39-
<label for="exampleInputEmail1" class="form-label">Full Name</label>
40-
<input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
40+
<label class="form-label">Full Name</label>
41+
<input name="name" type="text" class="form-control" value="{{Auth::user()->name}}">
4142
</div>
4243
<div class="mb-4">
43-
<label for="exampleInputEmail1" class="form-label">Email Address</label>
44-
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
44+
<label class="form-label">Email Address</label>
45+
<input name="email" type="email" class="form-control" value="{{Auth::user()->email}}">
4546
</div>
4647
<div class="mb-4">
47-
<label for="exampleInputEmail1" class="form-label">Occupation</label>
48-
<input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
48+
<label class="form-label">Occupation</label>
49+
<input name="occupation" type="text" class="form-control" value="{{Auth::user()->occupation}}">
4950
</div>
5051
<div class="mb-4">
51-
<label for="exampleInputEmail1" class="form-label">Card Number</label>
52-
<input type="number" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
52+
<label class="form-label">Card Number</label>
53+
<input name="card_number" type="number" class="form-control">
5354
</div>
5455
<div class="mb-5">
5556
<div class="row">
5657
<div class="col-lg-6 col-12">
57-
<label for="exampleInputEmail1" class="form-label">Expired</label>
58-
<input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
58+
<label class="form-label">Expired</label>
59+
<input name="expired" type="month" class="form-control">
5960
</div>
6061
<div class="col-lg-6 col-12">
61-
<label for="exampleInputEmail1" class="form-label">CVC</label>
62-
<input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
62+
<label class="form-label">CVC</label>
63+
<input name="cvc" type="number" class="form-control" maxlength="3">
6364
</div>
6465
</div>
6566
</div>

resources/views/checkout-success.blade.php renamed to resources/views/checkout/success.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<h2 class="primary-header ">
1919
Berhasil Checkout
2020
</h2>
21-
<a href="#" class="btn btn-primary mt-2">
21+
<a href="{{route('dashboard')}}" class="btn btn-primary mt-2">
2222
My Dashboard
2323
</a>
2424
</div>

resources/views/components/navbar.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class="navbar-toggler"
4646
<a href="#" class="dropdown-item">Profile</a>
4747
</li>
4848
<li>
49-
<a href="#" class="dropdown-item">Dashboard</a>
49+
<a href="{{route('dashboard')}}" class="dropdown-item">Dashboard</a>
5050
</li>
5151
<li><hr class="dropdown-divider"></li>
5252
<li>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
@extends('layouts.app')
2+
3+
@section('title')
4+
Dashboard
5+
@endsection
6+
7+
@section('content')
8+
<section class="dashboard my-5">
9+
<div class="container">
10+
<div class="row text-left">
11+
<div class=" col-lg-12 col-12 header-wrap mt-4">
12+
<p class="story">
13+
DASHBOARD
14+
</p>
15+
<h2 class="primary-header ">
16+
My Courses
17+
</h2>
18+
</div>
19+
</div>
20+
<div class="row my-5">
21+
<table class="table">
22+
<tbody>
23+
@forelse ($checkouts as $checkout)
24+
<tr class="align-middle">
25+
<td width="18%">
26+
<img src="{{asset('assets/item_bootcamp.png')}}" height="120" alt="">
27+
</td>
28+
<td>
29+
<p class="mb-2">
30+
<strong>{{$checkout->Camp->title}}</strong>
31+
</p>
32+
<p>
33+
{{$checkout->created_at->format('d M, Y')}}
34+
</p>
35+
</td>
36+
<td>
37+
<strong>${{$checkout->Camp->price}},00</strong>
38+
</td>
39+
<td>
40+
@if ($checkout->is_paid)
41+
<strong class="text-success">Success</strong>
42+
@else
43+
<strong class="text-primary">Waiting for Payment</strong>
44+
@endif
45+
</td>
46+
<td>
47+
<a href="https://wa.me/628xxx?text= Halo, saya ingin bertanya tentang kelas {{$checkout->Camp->title}}" target="_blank" class="btn btn-primary">
48+
Contact Support
49+
</a>
50+
</td>
51+
</tr>
52+
@empty
53+
<tr class="align-middle">
54+
<div class="alert alert-info" role="alert">
55+
Belum Memiliki Kelas!
56+
</div>
57+
</tr>
58+
@endforelse
59+
</tbody>
60+
</table>
61+
</div>
62+
</div>
63+
</section>
64+
@endsection

resources/views/welcome.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
<div class="row">
178178
<div class="col-lg-6 col-12">
179179
<div class="table-pricing paket-gila">
180-
<p class="story text-center">GILA BELAJAR</p>
180+
<p class="story text-center">PAKET HYPE</p>
181181
<h1 class="price text-center">$280K</h1>
182182
<div class="item-benefit-pricing mb-4">
183183
<img src="{{asset('assets/ic_check.svg')}}" alt="" />
@@ -227,15 +227,15 @@
227227
<div class="clear"></div>
228228
</div>
229229
<p>
230-
<a href="{{route('checkout')}}" class="btn btn-master btn-primary w-100 mt-3">
230+
<a href="{{route('checkout.create', 'paket-hype')}}" class="btn btn-master btn-primary w-100 mt-3">
231231
Take This Plan
232232
</a>
233233
</p>
234234
</div>
235235
</div>
236236
<div class="col-lg-6 col-12">
237237
<div class="table-pricing paket-biasa">
238-
<p class="story text-center">BARU MULAI</p>
238+
<p class="story text-center">PAKET BAYI</p>
239239
<h1 class="price text-center">$140K</h1>
240240
<div class="item-benefit-pricing mb-4">
241241
<img src="{{asset('assets/ic_check.svg')}}" alt="" />
@@ -261,7 +261,7 @@
261261
<div class="clear"></div>
262262
</div>
263263
<p>
264-
<a href="{{route('checkout')}}" class="btn btn-master btn-secondary w-100 mt-3">
264+
<a href="{{route('checkout.create', 'paket-bayi')}}" class="btn btn-master btn-secondary w-100 mt-3">
265265
Start With This Plan
266266
</a>
267267
</p>

routes/web.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22

33
use Illuminate\Support\Facades\Route;
4+
use App\Http\Controllers\HomeController;
45
use App\Http\Controllers\UserController;
6+
use App\Http\Controllers\User\CheckoutController;
57

68
/*
79
|--------------------------------------------------------------------------
@@ -22,22 +24,21 @@
2224
return view('login');
2325
})->name('login');
2426

25-
Route::get('checkout', function () {
26-
return view('checkout');
27-
})->name('checkout');
28-
29-
Route::get('success-checkout', function () {
30-
return view('checkout-success');
31-
})->name('checkout.success');
3227

3328
// socialite routes
3429
Route::get('sign-in-google', [UserController::class, 'google'])->name('user.login.google');
3530

3631
Route::get('auth/google/callback', [UserController::class, 'handleProviderCallback'])->name('user.google.callback');
3732

3833

39-
Route::get('/dashboard', function () {
40-
return view('dashboard');
41-
})->middleware(['auth'])->name('dashboard');
34+
Route::middleware('auth')->group(function(){
35+
// Checkout routes
36+
Route::get('checkout/success', [CheckoutController::class, 'success'])->name('checkout.success');
37+
Route::get('checkout/{camp:slug}', [CheckoutController::class, 'create'])->name('checkout.create');
38+
Route::post('checkout/{camp}', [CheckoutController::class, 'store'])->name('checkout.store');
39+
40+
//
41+
Route::get('dashboard', [HomeController::class, 'dashboard'])->name('dashboard');
42+
});
4243

4344
require __DIR__.'/auth.php';

0 commit comments

Comments
 (0)