Hi,
It's my first post and, in fact, isn't properly a question, but a request for suggestions because my problem, for now, it's solved. I hope there's a better and elegant solution from my issue.
The majority of tutorials for begginers about Laravel on Internet explain how to make a new solution, using the Eloquent patterns. But it's hard to find tutorials and articles talking about migrations from legacy databases and systems to Laravel's architecture.
I use MySQL and the columns' names are sometime in uppercase sometime in lowercase. And when I try to show the data on my View, I have to guess that.
@foreach($users as $user)
<p>Name: {{ $user->name }}</p>
@endforeach
The code above returns nothing, but the code bellow shows the user's names:
@foreach($users as $user)
<p>Name: {{ $user->NAME}}</p>
@endforeach
To solve my issue, I have to do that on my Model:
public function __get($key)
{
if (is_null($this->getAttribute($key))) {
return $this->getAttribute(strtoupper($key));
} else {
return $this->getAttribute($key);
}
}
Is it a god solution? How can I have a better one?
Thanks in advance the help!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community