-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vilgefortzz
committed
May 19, 2017
1 parent
ad3ba52
commit 068b08d
Showing
31 changed files
with
1,555 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Cart; | ||
use App\Order; | ||
use Auth; | ||
use Illuminate\Http\Request; | ||
use Session; | ||
|
||
class OrderController extends Controller | ||
{ | ||
public function showCheckout(){ | ||
|
||
if (!Session::has('cart')){ | ||
return back(); | ||
} | ||
|
||
$oldCart = Session::get('cart'); | ||
$cart = new Cart($oldCart); | ||
|
||
return view('orders.checkout', ['products' => $cart->products, 'totalPrice' => $cart->totalPrice]); | ||
} | ||
|
||
public function showPlaceAnOrder(){ | ||
|
||
if (!Session::has('cart')){ | ||
return back(); | ||
} | ||
|
||
$oldCart = Session::get('cart'); | ||
$cart = new Cart($oldCart); | ||
|
||
return view('orders.place_an_order', ['products' => $cart->products, 'totalPrice' => $cart->totalPrice]); | ||
} | ||
|
||
public function store(Request $request){ | ||
|
||
/* | ||
* Validate data | ||
*/ | ||
|
||
$this->validate($request, [ | ||
'email' => 'required|email|max:255', | ||
'first_name' => 'required|min:3|max:30', | ||
'last_name' => 'required|min:5|max:50', | ||
'street' => 'required|min:5|max:50', | ||
'postal_code' => 'required|min:5|max:20', | ||
'city' => 'required|min:5|max:15', | ||
'phone_number' => 'required' | ||
]); | ||
|
||
/* | ||
* Get items, total price from shopping cart | ||
*/ | ||
if (!Session::has('cart')){ | ||
return back(); | ||
} | ||
|
||
$oldCart = Session::get('cart'); | ||
$cart = new Cart($oldCart); | ||
|
||
// Create order | ||
$order = new Order(); | ||
|
||
if (Auth::check()){ | ||
$order->user_id = Auth::user()->id; | ||
} | ||
|
||
$order->total_paid = $cart->totalPrice; | ||
$order->delivery_method = $request->delivery_methods; | ||
$order->payment_method = $request->payment_methods; | ||
$order->status = "New"; | ||
$order->save(); | ||
|
||
Session::flush(); | ||
return redirect()->to('/madeAnOrder'); | ||
} | ||
|
||
public function showMadeAnOrder(){ | ||
|
||
return view('orders.made_order'); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.