Laravel Tips & Tricks

In this article we will share some of the top laravel tips and tricks with you.

#1 – Push Method

Save the model and all of its relationships at once using the `push` method 🙃.

Laravel tips and tricks :  Push Method
Push Method

#2 – getOriginal and getRawOriginal Method

The getRawOriginal method will actually grab the value from the $original array.

#3 – foreignIdFor Method

Basically, it creates a foreign key based on the class’s snake case appended by the primary key column.

#4 – Route Helper Function

By default, the route function is returning an absolute path, the full URL. If you pass in false, you only get the path back. This can be useful if you want to pass the URL to your frontend or if you want to display the URL in your application without the domain.

Leave a Comment

Your email address will not be published. Required fields are marked *