vanilophp / demo

Vanilo Demo Application
https://vanilo.io/docs/
190 stars 54 forks source link

checkout submit #1

Closed guilhermejuniorjuk closed 6 years ago

guilhermejuniorjuk commented 6 years ago

Illuminate \ Database \ QueryException (42S22) SQLSTATE[42S22]: Column not found: 1054 Unknown column 'shippingAddress' in 'field list' (SQL: insert into orders (status, shippingAddress, number, user_id, updated_at, created_at) values (pending, shipping, 550-1reg-bvu3, 1, 2018-03-27 22:49:28, 2018-03-27 22:49:28))

fulopattila122 commented 6 years ago

What's the code that resulted this exception? shippingAddress is a relation (-> addresses table), not a column.

guilhermejuniorjuk commented 6 years ago
namespace App\Http\Controllers;

use App\Http\Requests\CheckoutRequest;
use Konekt\Address\Models\CountryProxy;
use Vanilo\Cart\Facades\Cart;
use Vanilo\Checkout\Facades\Checkout;
use Vanilo\Order\Contracts\OrderFactory;

class CheckoutController extends Controller
{
    public function show()
    {
        $checkout = false;

        if (Cart::isNotEmpty()) {
            $checkout = Checkout::getFacadeRoot();
            if ($old = old()) {
                $checkout->update($old);
            }

            $checkout->setCart(Cart::model());
        }

        return view('checkout.show', [
            'checkout'  => $checkout,
            'countries' => CountryProxy::all()
        ]);
    }

    public function submit(CheckoutRequest $request, OrderFactory $orderFactory)
    {
        $checkout = Checkout::getFacadeRoot();
        $checkout->update($request->all());
        $checkout->setCart(Cart::model());

        $order = $orderFactory->createFromCheckout($checkout);
        flash("Order created: " . $order->getNumber());
        Cart::destroy();

        return redirect()->route('shop.index');
    }
}

I made the default installation of Vanilo and I used the controllers and views examples of Vanilo Demo

fulopattila122 commented 6 years ago

Default installation, you mean this: https://vanilo.io/docs/0.2/installation ?

guilhermejuniorjuk commented 6 years ago

yes

fulopattila122 commented 6 years ago

OK, I'll take a look into it.

guilhermejuniorjuk commented 6 years ago

I did the Vanilo Demo Application installation and the problem was solved

fulopattila122 commented 6 years ago

OK, cool. I'll still review the installation process, because it might be incorrect. Thanks for the report anyways! 👍

guilhermejuniorjuk commented 6 years ago

run composer update, and update vanilo / order to v 0.2.1 this issue returned, this problem must be in some change in v 0.2.1

fulopattila122 commented 6 years ago

The fix has been released with vanilo/order v0.2.2