How to increment or decrement in Laravel in one line
When dealing with product stock, you may need to update the current stock based on a delivery or sale. With Laravel, you can have some clean and tidy lines of code for that.
Coursecomp is your starting point for developing and maintaining your web application.
When dealing with product stock, you may need to update the current stock based on a delivery or sale. With Laravel, you can have some clean and tidy lines of code for that.
Did you know that there are 4 ways to make validation in Laravel for incoming requests? Here they are: 1. Using Request Facades 2. Using Request helper 3. Using Validator Facade 4. Using Form Request
If you want to prevent unnecessary access to your cloud-based files, you can try temporary download URLs in Laravel. As an example, you can give your user the redirect URL to Amazon S3 storage, and that ULR expires in 5 seconds (it’s more than enough time, but you can play around with this value).
What is eager loading? This is an excellent concept for eloquent model in Laravel, when you retrieve the items, you are provided with all the related items at the same query. This eliminates the famous N+1 query problem.
While we have in_array function in PHP to check if a variable is present in array, we can do the same with Collections Method in Laravel.
If you need to return a downloadable file in Laravel, just do it with this easy technique – enable the download method on the response object. For example:
Hello friends. Sometimes you need to run tests that rely on specific time in the past or in the future. There is a useful trick to fake time for that purpose. Just set fake timestamps using now() helper or Carbon class. Here is the example:
You always learn something new with Git. For example, you have made many changes to the codebase and suddenly realize that you’re working on a master branch. That seems odd. So, the decision is just as simple as this: This command creates a new branch and brings all of your local changes over.
When you use the Laravel eloquent models on a non-default database connection, the default database transaction will not work. You have to specify the DB connection type before opening the transaction.
The science of creating database indexes is learned from experience and the right people, not to mention much more complicated multiple-column indexes. But it wasn’t supposed to be complex! Here are three simple pieces of advice for the column ordering of multiple column indexes, solving 90% of the performance issues. Three rules for Multiple-Column Indexes […]