1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Ticket;
use App\Order;
use App\Transaction;
use App\Http\Requests;
use App\Http\Requests\Ticket\StoreRequest;
use App\Http\Requests\Ticket\UpdateRequest;
use Illuminate\Support\Facades\DB;
use Sentinel;
use App\User;
class TicketController extends Controller
{
public function index()
{
$tickets = Ticket::all();
return view('customers.ticket.ticket_home', compact('tickets'));
}
public function update(Request $request, $id)
{
$orders = Order::find($id);
// $this -> validate($request, [
// 'images' => 'mime: jpg, jpeg, png | max:2024',
// ]);
if ($request->file('images') == "")
{
$orders->images = $orders->images;
return redirect('data_order')->with('alert-success', 'Resi pembayaran belum diupload');
}
else{
$file = $request->file('images');
$fileName = $file->getClientOriginalName();
$request->file('images')->move("image/", $fileName);
$orders->images = $fileName;
$orders->update();
return redirect('data_order')->with('alert-success', 'Resi pembayaran berhasil diunggah. Silahkan menunggu konfirmasi pembayaran anda');
}
}
public function destroy($id)
{
$tickets = Ticket::findOrFail($id);
$tickets->delete();
return redirect()->route('ticket.index')->with('alert-success', 'Data Berhasil Dihapus.');
}
public function beli($id){
$this->data['title'] = "Order";
$this->data['tickets'] = Ticket::find($id);
$tickets = DB::table('tickets')->where('id' , $id)->first();
if($tickets->name==''){
return redirect(url('/ticket'));
}else{
return view('customers.ticket.beli.index',$this->data);
}
$orders->save();
}
public function storeorder(Request $request)
{
$orders = new Order();
$orders->user_id = $request->user_id;
$orders->first_name = $request->first_name;
$orders->nama = $request->nama_ticket;
$orders->tanggal_kunjung = $request->tanggal_kunjung;
$orders->jumlah = $request->jumlah;
$jumlah = $request->jumlah;
$harga = $request->harga;
$total = $harga * $jumlah;
$orders->harga = $total;
$orders->save();
return redirect()->route('ticket.index')->with('alert-success', 'Ticket Success Ordered.
Please pay by transfer bank to 111-111-111 (ABC Bank).
Then, upload it in Data Pemesanan ');
}
public function lunas($id){
DB::table('orders')->where('id' , $id)->update(['status' => 1]);
$input = DB::table('orders')->where('id' , $id)->first();
$trans = new Transaction();
$trans->id_order = $input->id;
$trans->id_ticket = $input->id_ticket;
$trans->user_id = $input->user_id;
$trans->first_name = $input->first_name;
$trans->nama = $input->nama;
$trans->tanggal_kunjung = $input->tanggal_kunjung;
$trans->jumlah = $input->jumlah;
$trans->harga = $input->harga;
$trans->status = $input->status;
$trans->save();
return redirect()->back()->with('alert_success', 'Berhasil dikonfirmasi');
}
public function upload($id)
{
$orders = Order::findOrFail($id);
return view('customers.ticket.upload', compact('orders'));
}
public function dataorder()
{
$id = Sentinel::getUser()->id;
$users = DB::table('users')->where('id', $id)->first();
$id = $users->id;
$this->data['users'] = User::find($id);
$orders = DB::table('orders')->where('user_id', $id)->orderBy('id', 'desc')->where('status','=',0)->get();
return view('customers.ticket.data_order', compact('orders'));
}
public function datakonfirmasi()
{
$id = Sentinel::getUser()->id;
$users = DB::table('users')->where('id', $id)->first();
$id = $users->id;
$this->data['users'] = User::find($id);
$transactions = DB::table('transactions')->where('user_id', $id)->orderBy('id', 'desc')->get();
return view('customers.ticket.data_konfirmasi', compact('transactions'));
}
public function destroyorder($id)
{
$orders = Order::findOrFail($id);
$orders->delete();
return redirect()->back()->with('alert-success', 'Pemesanan dibatalkan');
}
public function datapesanan()
{
$orders = DB::table('orders')->orderby(
'id','desc')->where('status','=',0)->get();
return view('staffs.data_pemesanan', compact('orders'));
}
public function destroypemesanan($id)
{
$orders = Order::findOrFail($id);
$orders->delete();
return redirect()->back()->with('alert-success', 'Pemesanan tidak dikonfirmasi');
}
public function datatransaksi()
{
$transactions = DB::table('orders')->orderby(
'id','desc')->where('status','=',1)->get();
return view('staffs.data_transaksi', compact('transactions'));
}
}