Skip to main content

Search Results for "eloquent tips"

We found 20 results for "eloquent tips".

Haven't found what you're looking for?

Our team is here to help. Ask us anything about Laravel development and we'll get back to you with personalized guidance.

Ask for Personal Help

We'll respond within 24 hours

Function available only for premium members.

Be as specific as possible so we can provide the best guidance.

Tutorial Free

In Eloquent We Trust, or don't assume find() always finds something

This short lesson will be both about Laravel and about general software development. One of the most often and common mistakes made by developers is not checking input data. And then not only you get random errors of something "not found", but sometimes much worse - expose your system to vulnerabilities and attacks. So let's discuss that with examples from Eloquent world.

Tutorial Free

Why use $appends with Accessors in Eloquent?

Eloquent has a convenient feature called Accessors - you can define your own custom fields on top of existing in the database table. But then there's an Eloquent property $appends - should we use it or not? And what's the difference?

Tutorial Free

Stop checking if record exists: Eloquent methods OrCreate and OrNew

Another "hidden gem" of Laravel which is surprisingly rarely used or even known, though it's mentioned in the official Eloquent documentation. Imagine that you have a record, and you need to check if that record already exists in the database - to prevent duplicate, you wouldn't save it second time. There's an elegant way to perform it in Eloquent.

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.