Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Save model fields data only

Hi guys!

Tell me please, how save model data only to session, without metadata and other data?

$user = Users::findFirst($user_id);
$session->set('user', $user);

$user contains many unnecessary to store information. I need only the field values from the model. And it takes up much space.

Sorry for my english dialect :)

$session->set('user', $user->toArray());


Hmm.. its really. Thanks!

Also as ang argument for toArray method you can puts an array with columns you only need.

Hmm.. its really. Thanks!

Wojciech Ślawski, thanks too.