06. Better IDE support


Generally, when we invoke the QueryBuilder first before we start to train any methods on, it gives us better IDE support. Now, of course, this depends on the IDE that you're using. Whether you have any particular packages of your IDE that you've pulled in which assist
with this regardless of using the QueryBuilder method, most people will find it beneficial to use the QueryBuilder method just so you can click through to inspect things. So let's go ahead and look at an example of this. So I'm just going to define out a POST variable.
We'll just say WHERE slug, slug1, like we've seen before. And we'll go ahead and call that FIRST or FIRSTORFAIL method. And let's just die dump on that POST here. So let's come back over to our browser, give that a refresh, and yeah, we get 404 not found.
So let's see what's going on here. That's POST1, not slug1. There we go. So we've got it in there.
Now, with my editor, I can hold down my Option key and click on any of these methods. At the moment, I can't, though, because we're using that call magic method that we looked at in the first episode. This doesn't know where it's coming from.
I don't have anything installed in my editor specifically that allows me to inspect this. It doesn't recognize it within Laravel. So if we bring in that QueryBuilder method, which we know returns a new builder instance, my IDE now knows what these methods are and where they belong.
So I can click on this and go directly through to this so I can see what this takes in. I can review the code just to see how this works. I can click on this and see what happens when this works. And of course, this is very simple, but once things start to get a little bit more complicated,
this can be really, really useful for you to just jump straight over to these builder methods. So you might find some sort of package that handles this for you specifically within Laravel, or you can just go ahead and use the QueryBuilder method to get this support within your IDE.
7 episodes 23 mins


Ever used the Eloquent query() method in Laravel before? In this short course, we'll dive into what this method does, and demonstrate the ways it can be used.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!


No comments, yet. Be the first to leave a comment.