Skip to content

Commit c6b2fbb

Browse files
committed
pos working
1 parent cc1c299 commit c6b2fbb

File tree

5 files changed

+340
-39
lines changed

5 files changed

+340
-39
lines changed
+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use App\Models\Customer;
6+
use App\Models\Setting;
7+
use Gloudemans\Shoppingcart\Facades\Cart;
8+
use Illuminate\Http\Request;
9+
10+
11+
class CartController extends Controller
12+
{
13+
//add to cart
14+
public function add_cart(Request $request){
15+
$AddCart = Cart::add(['id' => $request->id, 'name' => $request->name, 'qty' => $request->qty, 'price' => $request->price]);
16+
17+
if ($AddCart) {
18+
$notification = array(
19+
'message' => 'Add to Cart Successfull',
20+
'alert-type' => 'success'
21+
);
22+
return redirect()->back()->with($notification);
23+
} else {
24+
return redirect()->back();
25+
}
26+
27+
}
28+
29+
30+
31+
//update cart qty
32+
public function cart_update(Request $request,$rowId){
33+
34+
$cart_qty_update = Cart::update($rowId, ['qty' => $request->qty]); // Will update the qty
35+
36+
if ($cart_qty_update) {
37+
$notification = array(
38+
'message' => 'Cart Quantity Updated',
39+
'alert-type' => 'success'
40+
);
41+
return redirect()->back()->with($notification);
42+
} else {
43+
return redirect()->back();
44+
}
45+
}
46+
47+
48+
//selected cart item remove
49+
public function cart_item_remove($rowId){
50+
$cart_item = Cart::remove($rowId);
51+
$notification = array(
52+
'message' => 'Selected Item Remove',
53+
'alert-type' => 'info'
54+
);
55+
return redirect()->back()->with($notification);
56+
}
57+
58+
//cart invoice
59+
public function invoice(Request $request){
60+
$request->validate([
61+
'cus_id'=>'required|numeric',
62+
],
63+
[
64+
'cus_id' => 'place select customer',
65+
]);
66+
$setting = Setting::latest()->first();
67+
$customer_info = Customer::find($request->cus_id);
68+
return view('dashbord.Pos.invoice',compact('customer_info','setting'));
69+
}
70+
}

config/app.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
* Package Service Providers...
161161
*/
162162
Maatwebsite\Excel\ExcelServiceProvider::class,
163-
163+
164164
/*
165165
* Application Service Providers...
166166
*/
@@ -185,6 +185,7 @@
185185
'aliases' => Facade::defaultAliases()->merge([
186186
// 'Example' => App\Facades\Example::class,
187187
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
188+
'Cart' => Gloudemans\Shoppingcart\Facades\Cart::class,
188189

189190
])->toArray(),
190191

resources/views/dashbord/Pos/index.blade.php

+77-38
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<div style="margin-left: 3px">
3838
<span >All Category</span>
3939
@foreach ($Category as $Category_item)
40-
<span class="btn btn-primary">{{ $Category_item->category_name }}</span>
40+
<span class="btn btn-primary " style="margin-top: 2px">{{ $Category_item->category_name }}</span>
4141
@endforeach
4242

4343
</div>
@@ -47,18 +47,7 @@
4747
<div class="row">
4848
<div class="col-md-5">
4949
<div class="panel">
50-
<div class="row">
51-
<div class="col-sm-7">
52-
<select class="form-control">
53-
@foreach ($Customer as $customer)
54-
<option>{{ $customer->name }}</option>
55-
@endforeach
56-
</select>
57-
</div>
58-
59-
<button class="btn btn-primary waves-effect waves-light" data-toggle="modal" data-target="#custom-width-modal">Add Cusstomer</button>
6050

61-
</div>
6251
<br>
6352
<div class="price_card text-center">
6453
<table class="table table-striped table-bordered">
@@ -72,31 +61,72 @@
7261
</tr>
7362
</thead>
7463
<tbody>
75-
<tr>
76-
<td>Name</td>
77-
<td>
78-
<form action="" method="post" style="margin-top: -20px">
79-
<input type="text" min="1" style="width: 40%">
80-
<button type="submit"> <i class="md md-done"></i></button>
81-
</form>
82-
</td>
83-
<td>100</td>
84-
<td>100</td>
85-
<td>
86-
<a class="btn btn-icon waves-effect waves-light btn-danger "> <i class="fa fa-remove"></i> </a>
87-
</td>
88-
</tr>
64+
{{-- show cart item start--}}
65+
<?php
66+
$cart_item_show = Cart::content();
67+
?>
68+
{{-- show cart item End--}}
69+
@foreach ($cart_item_show as $cart_item)
70+
<tr>
71+
<td>{{ $cart_item->name }}</td>
72+
<td>
73+
<form action="{{ route('update.cart',$cart_item->rowId) }}" method="post" style="margin-top: -20px">
74+
@csrf
75+
<input type="number" min="1" style="width: 40%" value="{{ $cart_item->qty }}" name="qty">
76+
<button type="submit"> <i class="md md-done"></i></button>
77+
</form>
78+
</td>
79+
<td>{{ $cart_item->price }}</td>
80+
<td>{{ $cart_item->price*$cart_item->qty }}</td>
81+
<td>
82+
<a href="{{ route('remove.cart.item',$cart_item->rowId) }}" class="btn btn-icon waves-effect waves-light btn-danger "> <i class="fa fa-remove"></i> </a>
83+
</td>
84+
</tr>
85+
@endforeach
8986
</tbody>
9087
</table>
9188

9289
<div class="pricing-header bg-primary">
93-
<span>Total Quentaty :</span><br>
94-
<span>Total Price :</span><br>
95-
<button class="btn btn-danger waves-effect waves-light w-md">Invoic</button>
90+
<span>Total Quentaty : {{ Cart::count(); }}</span><br>
91+
<span>Price : {{ Cart::subtotal(); }}</span><br>
92+
<span>Vat : {{ Cart::tax(); }} (5%)</span><br>
93+
<span>Total Price : {{ Cart::total(); }}</span><br>
94+
95+
9696

9797
</div>
98+
99+
98100
</div>
101+
<form action="{{ route('cart.invoice') }}" method="post">
102+
@csrf
103+
<div class="row">
104+
@if ($errors->any())
105+
@foreach ($errors->all() as $error)
106+
<ul>
107+
<li>
108+
<p class="text-light">{{ $error }}</p>
109+
</li>
110+
</ul>
111+
@endforeach
112+
@endif
113+
<div class="col-sm-7">
114+
<select class="form-control" name="cus_id">
115+
<option >Select Customer</option>
116+
@foreach ($Customer as $customer)
117+
<option value="{{ $customer->id }}">{{ $customer->name }}</option>
118+
@endforeach
119+
</select>
120+
</div>
121+
122+
<button class="btn btn-primary waves-effect waves-light" data-toggle="modal" data-target="#custom-width-modal">Add Cusstomer</button>
123+
124+
</div>
125+
<button type="submit" class="btn btn-danger waves-effect waves-light" style="margin-left: 40%;margin-top: 5%;margin-bottom: 2%;">Invoice</button>
126+
</form>
127+
99128
</div>
129+
100130
</div>
101131
<!-- sample modal content -->
102132
<div id="custom-width-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="custom-width-modalLabel" aria-hidden="true" style="display: none;">
@@ -193,20 +223,29 @@
193223
<th>Category</th>
194224
<th>Code</th>
195225
<th>Price </th>
196-
226+
<th>Action</th>
197227
</tr>
198228
</thead>
199229
@foreach ($product as $item)
230+
200231
<tr>
201-
<td>
202-
<a href="" style="font-size: 20px;" class="m-b-4"><i class="md md-add"></i></a>
203-
<img style="width: 60px; height: 60px; " src="{{ asset('upload/product_image') }}/{{ $item->product_image }}" >
204-
</td>
205-
<td>{{ $item->product_name }}</td>
206-
<td>{{ $item->category_name }}</td>
207-
<td>{{ $item->product_code }}</td>
208-
<td>{{ $item->seling_price }}</td>
232+
<form action="{{ route('add.cart') }}" method="post" enctype="multipart/form-data">
233+
@csrf
234+
<input type="hidden" name="id" value="{{ $item->id }}">
235+
<input type="hidden" name="name" value="{{ $item->product_name }}">
236+
<input type="hidden" name="qty" value="1">
237+
<input type="hidden" name="price" value="{{ $item->seling_price }}">
238+
<td>
239+
<img style="width: 60px; height: 60px; " src="{{ asset('upload/product_image') }}/{{ $item->product_image }}" >
240+
</td>
241+
<td>{{ $item->product_name }}</td>
242+
<td>{{ $item->category_name }}</td>
243+
<td>{{ $item->product_code }}</td>
244+
<td>{{ $item->seling_price }}</td>
245+
<td> <button type="submit" class="btn btn-primary"><i class="md md-add"></i></button></td>
246+
</form>
209247
</tr>
248+
210249
@endforeach
211250

212251
<tbody>

0 commit comments

Comments
 (0)