Closed ITwrx closed 8 years ago
if(Auth::user()) { $shopItem = ShopItem::find(1); $cart =Cart::current(); $cart->add($shopItem); }
i've updated my issue to indicate that my user is logged in. it still happens with or without the auth check, as well, as the user is logged in. thanks
solution of the problem
Config::get('auth.model') replace Config::get('auth.providers.users.model') laravel 5.2 config('auth.providers.users.model')
You can simply add 'model' => App\User::class,
to your auth config.
@wildturk I tried replacing Config::get('auth.model') with Config::get('auth.providers.users.model') in ShopCartTrait.php but that didn't do the trick. am i misunderstanding you or is there somewhere else?
@fwartner I already had:'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\User::class, ], // 'users' => [ // 'driver' => 'database', // 'table' => 'users', // ], ],
in my Auth.php
Thanks for the input.
Doesn´t matter.. You need to use the old one additionally..
Am 30.01.2016 um 15:36 schrieb ITwrx notifications@github.com:
@wildturk https://github.com/wildturk I tried replacing Config::get('auth.model') with Config::get('auth.providers.users.model') in ShopCartTrait.php but that didn't do the trick. I i misunderstanding you or is there somewhere else?
@fwartner https://github.com/fwartner I already had:'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\User::class, ], // 'users' => [ // 'driver' => 'database', // 'table' => 'users', // ], ], in my Auth.php
Thanks for the input.
— Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/31#issuecomment-177193048.
@fwartner Thanks, but i don't understand what you're trying to tell me. I currently have 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\User::class, ], ],
what am i supposed to have in Auth.php instead?
You can simply leave it as it is atm.. But to get the package working, you´ll need to add the model-binding like i mentioned before.. Took me a few hours to figure out, why the package wouldn´t work for me.. ^^ But now it´s working..
Am 30.01.2016 um 19:30 schrieb ITwrx notifications@github.com:
@fwartner https://github.com/fwartner Thanks, but i don't understand what you're trying to tell me. I currently have 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\User::class, ], ],
what am i supposed to have in Auth.php instead?
— Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/31#issuecomment-177268159.
i finally got it, thanks. my Auth.php needed to be 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\Models\User::class, ], ],
because that's where my user model is. I thought i had tried that already but i guess not. :)
Glad to see.. :)
Am 30.01.2016 um 20:04 schrieb ITwrx notifications@github.com:
i finally got it, thanks. my Auth.php needed to be 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\Models\User::class, ], ], because that's where my user model is. I thought i had tried that alreadyt but i guess not. :)
— Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/31#issuecomment-177278021.
There´s one strongly recommended point for this package that NEED to do asap! The ability to store cart-items as a guest.. One of my clients need it in his project..
I guess it could be done using the session-helpers.. But i dunno how to re-use the session in case a user is going to sign up and store his cart in the database.. :/
Am 30.01.2016 um 20:04 schrieb ITwrx notifications@github.com:
i finally got it, thanks. my Auth.php needed to be 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\Models\User::class, ], ], because that's where my user model is. I thought i had tried that alreadyt but i guess not. :)
— Reply to this email directly or view it on GitHub https://github.com/amsgames/laravel-shop/issues/31#issuecomment-177278021.
The Documentation says that the guest cart is in the Horizon... :+1: lets see..
@fwartner yeah, good luck with it. I haven't even looked at it as i don't need guest cart right now. If it's for a new project you might find a suitable alternative cart package as there's been several laravel compatible cart projects show up on the scene lately.
update:
The config change mentioned above allowed Cart::current() to work but i later had trouble adding an item to cart. Changing return $this->belongsTo(Config::get('auth.model'), 'user_id');
to return $this->belongsTo(config('auth.providers.users.model'));
on line 56 in vendor/amsgames/laravel-shop/src/Traits/ShopCartTrait.php did the trick as widlturk suggested. Thanks
with logged in user $cart = Cart::current(); in my controller causes
and further down
i also notice
in ShopCartTrait.php
but auth.model is different in L5.2's config/auth.php. Maybe the $user problems start there?
Thanks