Open n-osennij opened 6 years ago
This is possible because Auth::user() is null while controller destructing, maybe. Но это не точно ))
@rariteth No. If try this
public function __destruct()
{
dd(Auth::user()->id);
Cart::store(Auth::user()->id);
}
I can see id of my user at the page. So Auth::user() not null while controller destructing
public function __destruct()
{
// dd(Auth::user()->id);
dd(Cart::content());
Cart::store(Auth::user()->id);
}
Cart data I can see too.
Try this:
\Log::debug(\Auth::user()->id);
to be completely sure
Unfortunately this is big deal to save Cart items and restore every request. Why cart items is deleted while restoring? I thing is it bug.
\Log::debug(\Auth::user()->id);
return null
Hmm... What can I do with it?
This is very strange, because in DB in field identefer
I can see usser id. Or if I do next - Cart::store(Auth::user());
I can see all user data in DB in field identefer
If you testing through dd your session is alive! Its a magic )))
my ugly code maybe helps you - https://pastebin.com/DEzC5xsu
@rariteth I think need to replace all serialize
in this repo to json_encode
and unserialize
to json_decode
Apache 7.2 PHP 7.2 MariaDB 10.2 Laravel 5.5.42 gloudemans/shoppingcart 2.5.0
In my CartCotroller I have next
Data is not saving to
shoppingcart
table. Incontent
field I have only part nextOnly this piece of code. No more. As result data not restored from DB