You're refetching Auth::user
in the second call and as such your changes in the first line go away.
$user = Auth::user()->expires_at = strtotime("+". $packDuration." months",time());
$user->save();
or just plain:
Auth::user()->expires_at = strtotime("+". $packDuration." months",time())->save();
Hi thank you for your reply, but i dont tkink this can work !
In the both examples you are calling the save method from the strtotime function not from the model, i tried and "call to a member function save() on a non-object"
In my first example i show you "expires_at" but its not the only things i save !
$packDuration = Pack::find($buy_info['pack_id'])->duration;
Auth::user()->pack_id = $buy_info["pack_id"];
Auth::user()->expires_at = strtotime("+". $packDuration." months",time());
Auth::user()->save();
My user pack_id is well saved in DB and session. :/
My expires_at is fillable in my model.
Auth::user()->expires_at = strtotime("+". $packDuration." months",time());
Doesn't this need to be like:
Auth::user()->expires_at = date('Y-m-d H:i:s', strtotime("+". $packDuration." months",time()));
Thank you very much.
Timestamps and dates has always been my nightmare. I don't get why i have to put a date in a timestamp column but ok.
Thank you again you saved my day. =)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community