public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Sale::create(['branch_id' => $faker->numberBetween($min = 1, $max = 10), 'cashier_sales_id' => $faker->numberBetween($min = 1, $max = 10), 'sales_total' => $faker->numberBetween($min = 100, $max = 1000), 'customer_change' => $faker->numberBetween($min = 1, $max = 100), 'number_of_items' => $faker->numberBetween($min = 1, $max = 10), 'vat_sales' => $faker->numberBetween($min = 5, $max = 12)]); } }
/** * Store a newly created sale in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Sale::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } Sale::create($data); return Redirect::route('sales.index'); }
public function processPayment() { // Set your secret key: remember to change this to your live secret key in production // See your keys here https://dashboard.stripe.com/account/apikeys Stripe::setApiKey("sk_live_NharL7KTJBPcvdVrbQIXr3MS"); // Get the credit card details submitted by the form $token = Input::get('stripeToken'); // Create the charge on Stripe's servers - this will charge the user's card try { if (Shipping::where('cart_id', Session::get('cart_id'))->pluck('payment_status') == 'Paid') { return Redirect::route('alreadyPaid'); } $charge = Charge::create(array("amount" => Input::get('data-description'), "currency" => "usd", "source" => $token, "description" => Session::get('cart_id'))); } catch (\Stripe\Error\Card $e) { // The card has been declined } $cart_id = Session::get('cart_id'); $markPaid = Shipping::where('cart_id', Session::get('cart_id'))->first(); $markPaid->payment_status = 'Paid'; $markPaid->shipped_status = 'Not Shipped'; $markPaid->save(); //inventorytime // foreach(Cart::where('customer_id', $cart_id)->get() as $purgeCarts) // { // $inventory = Inventory::where('product_id', $purgeCarts->item)->pluck($purgeCarts->size); // $newsize = $inventory - $purgeCarts->quantity; // DB::table('inventories')->where('product_id', $purgeCarts->item)->update(array($purgeCarts->size => $newsize)); // } Mail::send('emails.Newsale', array('cart' => $cart_id, 'customer' => Shipping::where('cart_id', $cart_id)->first()), function ($message) { $checkoutAmt = Session::get('checkoutAmt'); $message->to(Shipping::where('cart_id', Session::get('cart_id'))->pluck('email'))->subject("Your Eternally Nocturnal Order"); }); Mail::send('emails.Newsaleadmin', array('cart' => $cart_id, 'customer' => Shipping::where('cart_id', $cart_id)->first()), function ($message) { $checkoutAmt = Session::get('checkoutAmt'); $message->to('*****@*****.**')->subject("NEW SALE \$" . substr($checkoutAmt, 0, -2) . "." . substr($checkoutAmt, -2)); }); Sale::create(array('customer_id' => $markPaid->email, 'cart_id' => Session::get('cart_id'))); Session::forget('cart_id'); Session::forget('checkoutAmt'); return Redirect::route('transSuccess'); }