return $addressToString;
}
- public function getuser()
+ public function getuser(Request $request)
{
$user = Client::getClientConnected();
if ($user) {
];
$data = $this->validation_form($request, $validation);
+
$lastCartId = $request->session()->get('last_selection');
//
- $lastCartRefs = $lastCartId ? Cart::find($lastCartId)->getReferences() : [];
+ if ($lastCartId && Cart::find($lastCartId)) {
+ $lastCartRefs = $lastCartId ? Cart::find($lastCartId)->getReferences() : [];
+ } else {
+ $lastCartRefs = [];
+ }
$currentCartRef = Cart::getRefs($data['products']);
$intersect = $lastCartRefs ? array_intersect($currentCartRef, $lastCartRefs) : [];
*/
$data = Cart::fillData($currentCartRef, $data, $productsInfosBase, false);
+
+ $auth = auth('web-clients');
+ if (!$auth->guest()) {
+ $data['user_id'] = $auth->user()->id;
+ }
+
if (sizeof($lastCartRefs) !== sizeof($intersect) ||
(sizeof($lastCartRefs) === sizeof($intersect) && sizeof($currentCartRef) != sizeof($lastCartRefs))) {
$data["name"] = __("Panier du :date", ["date" => Carbon::now('Europe/Paris')->isoFormat("DD/MM/Y")]);
getUser() {
let root = this
- axios.post('/ajax/getuser')
+ axios.get('/ajax/getuser')
.then(function (response) {
root.user = response.data['user']
root.addresses = JSON.parse(root.user.address)