I have always used Eloquent very well with static methods. Yesterday, when creating a new session log concept for a new project, I came across a question I could not clarify.
I have a "Session" template that points to a table with the same name in the database. It happens that the moment the user passes the token, an object of class "Session" is created and its constructor tries to look for the record related to that token in the database. Usually I would use:
$sessao = Sessao::where('token',Input::get('token'))->get();
Or something like this:
$this->where('token',Input::get('token'))->get();
But in this case, I need to load the result into the object that made the query itself. Something like this:
$this = $sessao[0];
Of course this is out of the question. :) Another option would be:
$this->id = $sessao[0]->id;
$this->token = $sessao[0]->token;
And so on. Perhaps I have not understood very well how Eloquent works internally in the object. Is it possible to perform this loading dynamically?