A growing list of well built open-source apps in Laravel
October 6, 2024 — Sometimes, it would be interesting to see what you can build using your favorite framework. This is especially useful when you’re in the phase of selecting a framework for your next project.
The magic behind Laravel's new defer() helper
September 15, 2024 — Laravel has recently been shipped with a new helper called defer()
which can be used to defer the execution of a callback until after a successful response has been sent.
Temporary and Signed URLs for Local Filesystem in Laravel
September 14, 2024 — If you’re a long-time Laravel user, you might know about the feature that allows you to create temporary and signed URLs for files. This is a great feature that will enable you to share files with other users for a specified time.
Container Attributes in Laravel
September 8, 2024 — When you’re working with service classes in Laravel that you would inject into your controllers or anywhere else, you might need to pass some configuration values to them.
A package to easily backup database tables in Laravel
September 3, 2024 — Sometimes what happens is that for some reason, you might need to back up your database tables.
Keeping a check on queries in Laravel
August 6, 2024 — Being aware of the queries that are being executed in your application is one of the most important things to do if you want your application to be performant and scalable at all times.
Request fingerprints and how to use them in Laravel
July 20, 2024 — A fingerprint, in general, refers to a unique pattern or characteristic that can be used to identify an individual or an object. This concept is widely used in various fields.
Separating Database Hosts to Optimize Read and Write Operations in Laravel
July 15, 2024 — When it comes to database performance, it would be primarily judged by the fact that how well the database can handle read and write operations.
Using Generics in Laravel Eloquent
July 11, 2024 — Generics in programming are a feature that allows you to define functions, classes, and data structures with placeholder types. This enables you to write more flexible and reusable code.
Advanced Markdown using Extensions in Laravel
July 6, 2024 — Markdown has become a widely adopted standard for formatting text on the web due to its simplicity and readability. It allows users to write using an easy-to-read, easy-to-write plain text format, which is then converted to structurally valid HTML.
Finding cool Laravel developers using Laradir
July 1, 2024 — When you’re working with a certain technology stack, you often find yourself looking for developers who are using the same tools and frameworks. The like-minded developers can help you find the best solutions and improve your skills.
Multiply collections to fake bulk data in Laravel
June 27, 2024 — A lot of time when working with UIs, we need a big amount of data to check if the UI is working as expected in a real-world scenario.
Implementing SaaS Usage Limits in Laravel
June 23, 2024 — If you’ve ever worked with SaaS models, you’d be familiar with the concept of usage limits. It’s the most important metric for any SaaS product.
Fetching before and after items from a Laravel Collection
June 19, 2024 — There would be this rare scenario where you would want to fetch the before and after values from a Laravel Collection. For instance, you’re using a collection to display a resource from it and want to go back and forth from that value in that collection.
7 must-have packages for Laravel Developers
June 14, 2024 — Packages are a great way to extend the functionality of your Laravel application. They can be used to add new features, improve existing functionality, or enhance the performance of your application.
Three ways to impersonate a user in Laravel
June 10, 2024 — There comes a time when you want to log in or authenticate a user in your application manually. For instance, you have a functionality where admins can mimic a user to perform certain actions. Or you may just want to impersonate a user for testing purposes.
Larafast — A Laravel SaaS Starter Kit
June 5, 2024 — When it comes to building a SaaS product, Laravel essentially covers many things for you out of the box—things such as authentication, user management, notifications, queues, etc. You can further use first-party or third-party packages to add more features to your application.
The new freshly designed exception page in Laravel 11
May 30, 2024 — The attention to detail in everything that Laravel’s core team does is truly inspiring. Be it the clean code, the well-thought-out architecture, the thoughtful design decisions, or even the symmetry in the 3-line code comments, everything seems to be in the state of zen.
Sending mails using Resend in Laravel
May 29, 2024 — When it comes to sending emails, Laravel makes it a breeze of a task. Be it SMTP, Sendmail, Mailgun, or any other service, Laravel has got it all. You set the default mailer, the required API key/token in the .env
file, and you are good to go.
Cloning queries in Laravel
May 17, 2024 — Reusing database queries is a common practice to maintain clean, DRY (Don’t Repeat Yourself) code and ensure consistency across your application.
Return HTTP response as a collection (Effectively) in Laravel
May 8, 2024 — If you are using Laravel’s HTTP client to call a third-party API, you might want to use the response as a collection to manipulate the data.
The fluent data helper in Laravel
April 1, 2024 — When working with Laravel, you might need to manipulate data in various ways. For instance, when your data is a multi-dimensional array, you might need to filter, sort, or map the data to get the desired result.
Comparing a value against multiple columns the easy way in Laravel
March 7, 2024 — When working with Laravel, you might need to compare a value against multiple columns in the database. For instance, you might want to check if a value exists in one of the columns.
Define Observers and Global Scopes using PHP's Attributes in Laravel
February 15, 2024 — PHP 8’s Attributes are a great way to add metadata to your code. They are a form of structured, syntactic metadata that can be added to classes, methods, functions, and properties.
The new "select" method for Laravel Collections
February 14, 2024 — Do you remember the only
method in Laravel Collections that allows you to retrieve a subset of the items from the collection?
Quickly inspect the database and its tables in Laravel
January 25, 2024 — It’s sometimes convenient if you can quickly glance over the database your Laravel application is using and its tables. This is especially useful when you’re working on a legacy project and you’re not sure about the database structure.
APA-style titles in Laravel
January 16, 2024 — APA-style titles are a specific type of title case that is used in academic papers, research reports, and journal articles. It’s a style that’s used by the American Psychological Association (APA) and is a variation of the title case.
Detect leftovers like dd() and dump() in your Laravel codebase using Pest
December 14, 2023 — Debugging is an essential part of the development process. And when it comes to debugging in Laravel, the first thing that comes to mind is the dd()
and dump()
functions. These functions are used to dump the contents of a variable and stop the execution of the script.
Using arrays as a lightweight database in Laravel
December 12, 2023 — There are times when you don’t want to use a full-fledged database like MySQL or PostgreSQL for your application. For instance, if you’re building a small application that relies heavily on reading small subset of data, you might not want to setup a database table for something like that.
Auto-generate maintenance mode secret in Laravel
December 6, 2023 — Maintenance mode is a feature in Laravel that allows you to put your application down for maintenance. It’s a great way to inform your users that the application is down for maintenance and will be back up soon.
Real-time Application Performance Monitoring with Laravel Pulse
December 2, 2023 — After a lot of hype in Laravel AU 2023 about this secret project, Laravel Pulse is finally out in the wild. It’s a real-time application performance monitoring tool for Laravel applications.
Using any large JSON as a lazy collection in Laravel
November 30, 2023 — If you’re working with Laravel (or any PHP application for that matter), you might have stumbled upon a situation where you need to process a large JSON input. For instance, you might want to use a JSON file to seed your database.
The new Number utility in Laravel
November 22, 2023 — PHP has this NumberFormatter
class which is a part of the intl
extension. This class is used to format numbers based on the locale. I covered this in one of my previous articles.
Scroll to validation errors in Laravel using Alpine.js
November 20, 2023 — You know Laravel has this neat Blade directive called @error
which you can use to display the validation error message for a given field. For instance, if you have a name
field in your form and you want to display the validation error message for it, you can do it like so.
Response Code Cheat Sheet for Laravel HTTP Client
November 1, 2023 — Laravel’s HTTP client is a wrapper around PHP’s Guzzle HTTP Client library. It provides a fluent interface to communicate with HTTP endpoints. It can be used to make HTTP requests to external APIs or to communicate with your own application.
Prevent your Laravel application from various attacks using this package
October 9, 2023 — As your application grows in popularity, it becomes a target for various attacks. And even if not so popular, there are bots that are constantly looking for vulnerabilities in your application.
The new take() method to form substrings in Laravel
October 3, 2023 — Laravel has this method called substr()
(both in Illuminate\Support\Str
classes and str()
global helper) which is used to form substrings from a given string.
Pail — A Laravel Package for Tailing Logs
September 21, 2023 — A few days ago I discussed many ways to tail logs in Laravel. And it hasn’t been long since I wrote that article, a new package called Pail has popped up on my radar which is also a Laravel package for tailing logs.
A macro to produce AP-style headings in Laravel
September 20, 2023 — If you’re a journalist or a writer, you might be familiar with the AP Stylebook commonly known as “AP-style”. It’s a writing style guide for journalists and it’s widely used in the United States.
Fail-safe way of accessing environment variables in Laravel
September 14, 2023 — Environment variables are tricky little things that we use in our Laravel applications to store sensitive information such as API keys, database credentials, and so on. And there are two ways to access them in your Laravel application.
Artisan command to generate views in Laravel
September 14, 2023 — Laravel has all kinds of Artisan commands to let you generate boilerplate code for your application. For instance, you can generate a controller, model, migration, and so on using the Artisan command. But, there was no command to generate views in Laravel until now.
The many ways to tail the application log in Laravel
September 12, 2023 — Jeffery Way recently tweeted about how he wants a php artisan tail
command to see the real-time application logs in Laravel. And the replies to this tweet were quite interesting. People have shared their ways of tailing the Laravel log. So, I thought to compile them all in one place.
Benchmarking a callback and get its return value in Laravel
August 26, 2023 — You know Laravel always had the Illuminate\Support\Benchmark
helper function which you can use to benchmark a callback and print it. For instance, if you want to benchmark a callback function, here’s how you can do it.
Eloquent Strict Mode in Laravel
August 13, 2023 — Laravel’s Eloquent is a pretty powerful ORM. It allows you to seamlessly interact with your database tables using a simple and expressive syntax. But sometimes, it can be a little too forgiving about the mistakes you make while interacting with the database.
Using beautiful command prompts in Laravel
August 5, 2023 — Artisan commands in Laravel are truly a blessing. I mean you could create just about any files be it controllers, models, middleware, or provider by knocking a simple command from the CLI.
Ensure type uniformity of a collection in Laravel
August 3, 2023 — Sometimes, you may want to ensure that a collection in Laravel contains only a specific type of item. For instance, you may want to ensure that a collection contains only a string
type of item. Or, you may want to ensure that a collection contains items of a specific class.
An introduction to Laravel Folio
July 27, 2023 — If you’ve ever worked with Next.js, you might have come across its page routing system. It’s pretty straightforward. You just create a file with the name of the route you want to create and that’s it.
Reading large CSV Files as a Collection in Laravel
July 25, 2023 — Large-scale projects would often require to import data from large CSV files at some point. And if not handled properly, this can very well lead to memory issues.
Mass setting strict types to true using Laravel Pint
July 19, 2023 — Laravel Pint is a handy little package that helps you fix PHP code style in a Laravel project. On top of fixing code style, you can also set some rules and simplify repetitive tasks using this package.
Global HTTP middleware in Laravel 10.x
July 3, 2023 — Sometimes when working with third-party APIs, there might be a need to add common headers to all the outgoing requests. For instance, you might want to add an Authorization
header to all the outgoing requests to authenticate the requests.
Printing raw SQL queries with bindings in Laravel 10.x
July 2, 2023 — Perhaps the most anticipated feature that all Laravel developers were waiting for is finally going to be available in the framework. Yes, I’m talking about the ability to print raw SQL queries with bindings in Laravel 10.x.
Validating specific timezones in Laravel
May 26, 2023 — Laravel provides a timezone validation rule out of the box which you can use to validate if a given value is a valid timezone or not.
The new Sleep helper in Laravel 10.x
May 15, 2023 — If you’ve been using PHP for a while, you might have used its sleep function at some point to pause the execution of the script for a given number of seconds.
Piping system processes in Laravel
April 24, 2023 — Running system processes in Laravel is a common thing that we all need at some point. For instance, you might want to run a composer install
command or an npm install
command.
Rollback a specific migration in Laravel
April 17, 2023 — There comes a time when you want to make some changes to an existing table. For instance, you want to change the data type of a column. So, in this case, you can modify the migration file of the table and then run the migration again using the artisan migrate:refresh
command like so.
Using PER Coding Style with Laravel Pint
April 6, 2023 — When it comes to using a clean and consistent coding style across your Laravel project, the best way to do this is by using the Laravel Pint package. It’s a package that allows you to use the standard PSR coding style in your Laravel project.
Using existing HasMany relationships as HasOne in Laravel
March 31, 2023 — A HasMany
relationship in Laravel helps you to define a one-to-many relationship between two models. So, if you have a User
model and a Post
model, you can define a HasMany
relationship between them like so.
A Laravel macro for outputting possessive apostrophes correctly
March 26, 2023 — Macros in Laravel are gifts that keep on giving. They let you extend the functionality of Laravel in a way that you can use them anywhere in your application.
A handy File method to read JSON files in Laravel 10.x
March 22, 2023 — We now have a nice addition to the File
facade in Laravel 10.x that lets you read JSON files easily. Essentially, it’s a wrapper around the json_decode()
function. So, you can use it to read JSON files like so.
The pipeline helper in Laravel
March 9, 2023 — The Pipeline
facade is one little helper in Laravel that has been around for quite some time now but it’s only recently that it has got its place in the Laravel documentation.
Dynamic URLs with URI templates in Laravel
March 6, 2023 — There comes a time when you want to make HTTP requests but the URL using which you want to make the request is dynamic. For example, you want to make a request to the GitHub API to get the details of a user but the username is dynamic. Or the version of the API is dynamic.
The new helper to generate secure passwords in Laravel 10.x
February 19, 2023 — Oftentimes, you may need to generate a secure password for your users. And in such cases, you may use the Str::random()
method to generate a random string. But, the problem with this method is that it generates a random string that may not be secure enough.
A hurdle I faced while installing Laravel 10
February 16, 2023 — I was recently upgrading one of my Laravel apps to its newest version, i.e. Laravel 10. And while doing so, I faced a hurdle that I thought I should share with you.
Increment value of multiple columns at once in Laravel
January 22, 2023 — Laravel comes with handy little utilities when you want to increment or decrement the value of a column in a database table.
The setVisible and setHidden Eloquent methods in Laravel 9.x
January 11, 2023 — Laravel gives you a lot of flexibility when it comes to working with Eloquent models. You can easily customize the way you want to work with your models.
Useful macros to make Laravel routes compact
January 5, 2023 — Macros in Laravel are a great way to extend the framework’s functionality. And if you are a Laravel developer, you must have used them at some point.
Additional anonymous component paths in Laravel 9.x
December 27, 2022 — Anonymous components are a great way to create reusable components in Laravel. Essentially, you can create an anonymous component without creating an associated class. For example, you can do something like this.
Singleton routes for one-off resources in Laravel 9.x
December 7, 2022 — The way routes work in Laravel is that you define a route and then you define a controller action to handle the request.
Probability-based randomness using Lottery class in Laravel 9.x
November 16, 2022 — A minor version of Laravel 9.x has just been released and with this release, a new Lottery
class has been introduced.
File validation rule object in Laravel 9.x
November 12, 2022 — Validating things plays a crucial role in any web application. In Laravel, you can validate the incoming request data using the validate()
method. This method accepts an array of validation rules as its first argument. These rules are used to validate the incoming request data.
Rendering specific fragment of a blade view in Laravel 9.x
November 10, 2022 — Blade views are the most common way to render HTML in Laravel. But, what if you want to render a specific fragment of a blade view? For instance, you want to render a specific section of a blade view. Or, you want to render a specific component of a blade view.
Resolving middlewares statically from controllers in Laravel 9.x
October 29, 2022 — In Laravel, it’s possible to resolve middleware from controllers. For example, you can resolve a middleware from the controller’s constructor like so.
The new alternative mailable syntax in Laravel 9.x
October 24, 2022 — The latest version of Laravel 9.x has just been released and it comes with a lot of new features and improvements. In this article, I’ll talk about one of the new features in Laravel 9.x which is the new alternative mailable syntax.
Encrypting and decrypting environment files in Laravel 9.x
September 30, 2022 — The use of environment files in Laravel (or any other similar framework) is pretty common. You can use the .env
file to store the environment variables. This is a great way to store sensitive information like API keys, database credentials, etc. in a secure way.
Discard Eloquent model changes in Laravel 9.x
September 16, 2022 — In the recent Laravel 9.x release, the framework introduced a new discardChanges()
method on the Model
class. This method allows you to discard the changes made to the model instance. So, let’s see how we can use this method.
Why Developers Choose Cloudways For Laravel Hosting
August 25, 2022 — Laravel is an open-source PHP framework that forms web applications based on the model-view-controller paradigm. Hosting prerequisites include SSH to the server to deploy code from your GitHub store.
Accessing Laravel documentation from the terminal
August 2, 2022 — A new Laravel release just dropped and with that, a brand new feature is ready to embrace us.
The artisan about command in Laravel 9.x
July 20, 2022 — Recently, a minor release for Laravel 9.x has introduced many new features that mostly include the revamp/fresh new look of Artisan commands. This includes commands to handle migrations to clearing caches to handling queues.
New invokable rule objects in Laravel 9.x
July 19, 2022 — Validating incoming HTTP requests is an integral part of any robust web application and if you work with Laravel, it makes it a breeze to work with validation.
The global faker helper in Laravel 9.x
July 5, 2022 — How many times does this happens to you that when you’re building UIs, you add placeholders (“Lorem Ipsum”, “John Doe”, etc..) to the places where it needs data from database or external APIs?
Plural strings based on the count in Laravel
June 26, 2022 — Working with strings can prove to be tricky in some scenarios. For instance, when building a cart for an eCommerce website, you may need to show the string “item” in singular/plural form based on how many items are there in the cart.
Detecting slow database operations in Laravel 9.x
June 24, 2022 — When working with databases with web applications, you never know when some query, which used to work fine, starts slowing down in some scenarios.
How to validate JSON in Laravel
June 16, 2022 — I’m pretty sure if you’re older enough to be working in the software development industry, the one format that you would be working with in a recurring manner is JSON.
The new Arr::join() method in Laravel 9.x
May 7, 2022 — A while back, I have written an article on how to convert arrays to human-readable lists in JavaScript. It’s a built-in feature using the Intl.ListFormat
object that lets you do that.
The new findOr method in Laravel 9.x
May 2, 2022 — A minor release for Laravel 9.x dropped a few days ago and among lots of new features and improvements, this release has introduced a new method called findOr
in the Eloquent Builder and Relations.
Send emails to a single test email address for test environments in Laravel
April 23, 2022 — When you’re working on a Laravel application, chances are you might be working with a lot of emails. For instance, every time, a new user is created, a welcome email and a confirmation email will be sent to the user.
Override default 404 behavior in Laravel
April 22, 2022 — When working with Laravel routes, if it’s not able to find the matching route, a typical 404 HTTP response will be generated and returned back.
The new squish() helper in Laravel 9.x
April 12, 2022 — Oftentimes, we need to trim the user-entered input to remove the additional white spaces around the string.
Wrap string with other strings fluently in Laravel 9.x
March 31, 2022 — If you’ve ever been in a situation where you need to wrap your string with some characters, let’s say "
, you most probably would do something like so.
Clear all kinds of caches with a single command in Laravel
March 23, 2022 — There are mainly three kinds of caches in Laravel that you need to clear all the related junk files and optimize the performance of the application.
The new whereNot method in Laravel 9.x
March 4, 2022 — Sometimes, the things you would think are quite obvious and should exist without a doubt don’t exist at all.
The new str() and to_route() helpers in Laravel 9
February 12, 2022 — Before Laravel 9, when you wanted to interact with strings you would either use the Illuminate\Support\Str
class like so.
How to use Collections outside of Laravel
February 3, 2022 — The one feature of Laravel I truly admire is the Collections. Essentially, collections provide a fluent, convenient wrapper for working with arrays of data.
Swapping multiple keywords in a string in Laravel
February 1, 2022 — Sometimes, you might stumble upon a situation where you have some keywords and you want to replace those with certain keywords in the string.
Checking if the user is on the last page of pagination in Laravel 8.x
January 30, 2022 — Up until now, when you’re working with Laravel’s paginator and if you wanted to check whether the user is on the first page of the pagination in a Blade file, you would be using the onFirstPage()
method like so.
Grouping routes by controllers in Laravel 8.x
January 19, 2022 — There are many ways using which you can group your routes in Laravel right now. For instance, as by middlewares, subdomains, prefixes to name a few.
Reverting back to the original model instance in Laravel
January 16, 2022 — In Laravel, when you want to update the model that already exists in the database, you would first retrieve that model, set any attributes you wish to update, and then call the model’s save
method like so.
Improved single-method accessors and mutators in Laravel 8.x
December 27, 2021 — When you want to format certain Eloquent models before setting/retrieving in Laravel, you would certainly reach for the accessors and mutators.
Invisible MySQL columns in Laravel 8.x
December 21, 2021 — Let’s imagine a scenario where you have a MySQL table called users
and there’s a column called secret
which holds a secret token for the associated users.
Handy methods for unauthorized and forbidden responses in Laravel 8.x
December 20, 2021 — Working with Laravel’s HTTP client, there might be the scenario where the outgoing HTTP requests that you’re making might return responses with different status codes.
New undot() and reverse() methods in Laravel 8.x
December 4, 2021 — Some may argue that Laravel is a framework that is bloated with methods and stuff to do everything under the sun. But in my opinion, that’s one of those things that make Laravel, “Laravel” because the more options you have out of the box, the better your life gets!
Allow mass assignment for all the models in Laravel
November 20, 2021 — While it’s not recommended to allow all of your model’s attributes mass assignable since in that case you need to make sure to hand-craft the arrays passed to Eloquent’s fill
, create
, and update
methods.
Automatically remove models using Prunable trait in Laravel 8.x
November 14, 2021 — I recently saw a tweet by Philo Hermans which states the slick use of a recently added Prunable trait in Laravel 8.x
Mask part of a string in Laravel 8.x
November 6, 2021 — There comes a time when you would be in need of obfuscating a certain part of the string. For instance, to obfuscate the credit card’s digits except the last four or to mask specific parts of the phone number or email.
Make any string studly case using Str::headline() in Laravel 8.x
October 19, 2021 — Strings are tricky things to work with when it comes to programming. But thankfully, Laravel provides a lot of helper methods that can fulfill almost all the use-cases you might have when you’re working with strings.
Throwing response exceptions conditionally in Laravel 8.x
October 13, 2021 — When you’re using Laravel’s Http client to make Http requests and something went wrong from the server-side, the server would return one of the error reponses such as 500 Internal Server Error, 502 Gateway Timeout, and so on.
Retrieve request URL without specific query parameters in Laravel
September 24, 2021 — When you have a request in hand and if the URL is having a query string with different parameters, the easiest way to get the entire URL with the query string is using the fullUrl()
method like so.
The whereRelation (A better version of whereHas) method in Laravel 8.x
September 5, 2021 — Checking the existence of relationships and fetching model records is quite easy in Laravel.
Getting subsets of validated data in Laravel 8.x
August 21, 2021 — Laravel offers mainly two ways to validate the request data inside of the controller methods. Either you can directly call the validate
method on the Illuminate\Http\Request
object and set the validation rules or you can create a form request and type-hint the controller method with this form request class.
Conditional validation rules in Laravel 8.x
August 16, 2021 — Sometimes, you might end up in a situation where you would want to add certain validation rules for fields.
The new @class Blade directive in Laravel 8.x
July 31, 2021 — Sometimes, the biggest sign that shows that a framework is maturing is when it has multiple ways of doing the same thing. Laravel, being one of these frameworks, is no exception.
Outputting Eloquent query unparameterized in Laravel
July 24, 2021 — One of the many benefits of using Laravel as a framework is the immense customizability it comes with. So, you can use this to overcome some of the limitations.
Get all the changes applied by model updates in Laravel
July 20, 2021 — Here’s a little tip I get to know about Eloquent through this tweet by ninjaparade.
Global contextual logging in Laravel 8.x
June 30, 2021 — Logging is an integral part of developing applications. And if you’re working with Laravel, logging things is a breeze.
Artisan command to prune stale jobs in Laravel 8.x
June 29, 2021 — In Laravel, when your queued jobs fail after a job has exceeded the number of attempts, it will be inserted into the failed_jobs
database table (if you have set it up).
Send notifications to non-users of your application in Laravel
June 23, 2021 — Typically, when you send notifications from your Laravel app, the notifications would be attached to the users of your application in most of the scenarios.
Conditionally executing callbacks using Conditionable trait in Laravel 8.x
June 7, 2021 — If you have been working with Laravel lately, you might have used this feature called “conditional clauses” using which you will be able to run a certain callback when a condition becomes true
.
Blade stringable to handle objects centrally in Laravel 8.x
May 31, 2021 — Wouldn’t it be useful if you could define a certain action that should be performed every time your Blade templates encounter objects of a specific class?
Refresh maintenance mode page automatically in Laravel 8.x
May 25, 2021 — Laravel has this cool feature using which you can put your website in maintenance mode. To do so, all you will need to do is run the following command.
Estimated reading time macro in Laravel
May 5, 2021 — When you want to extend some of the classes’ functionality in Laravel, Macros are your best bet. Your imagination is the only limit to what you can do with macros.
Verify if entered password is compromised in data leak or not in Laravel 8.x
April 26, 2021 — In my previous article, I talked about the new custom password rule object which brings in the ability to easily add various validation rules to the password field.
The new custom password rule object in Laravel 8.x
April 25, 2021 — Passwords are sensitive data and they should be handled with utmost care. The one way to ensure that the user’s password remains safe is to make them enter the strong password in the first place.
Asynchronous HTTP client requests are coming in Laravel 8.x
Quick tip - Using lightweight pagination in Laravel
April 4, 2021 — If you want to paginate database records in Laravel, you can use the paginate
method on the query builder or an Eloquent query.
The prohibited validation rule in Laravel 8.x
March 30, 2021 — Sometimes, all you would need is to forcefully prevent some of the fields in the request. Essentially, to “prohibit” or ban the fields to be mandatorily empty or not present in the request at all.
Cleaner exception handling using rescue() helper in Laravel
March 22, 2021 — If you want to make your web application robust, you get to handle those quirky and unpredictable exceptions. And the way you do that in PHP is by using try-catch blocks in your code. The same applies in the case of Laravel as well.
Seeding model rows based on the user input in Laravel
March 15, 2021 — Oftentimes, it would be handy if you could seed the number of model rows based on the user input. i.e you don’t hardcode the number of rows a seeder would generate. The user will pass that number while running the seeder.
Dry running Laravel migrations before actually migrating them
March 11, 2021 — Sometimes, you might run into a situation where you want to see what all database queries will run upon running your Laravel migrations, and that too without actually running the migrations.
Retrieve HTTP response as a collection in Laravel 8.x
February 27, 2021 — Sometimes, when working with HTTP responses, you might want to retrieve the entire response as a Laravel collection to make further manipulations.
Adding lines conditionally in Laravel's Mail notifications
February 23, 2021 — When working with Mail notifications in Laravel, you’ll often be in a situation where you would want to render something based on some condition.
Mutation-free JSON column updation using AsArrayObject Eloquent cast
February 21, 2021 — If you have worked with a Large scale Laravel application, there might be a great chance that you would have to use JSON columns to save some information in your tables.
Tappable and pipeable fluent strings in Laravel 8.x
February 7, 2021 — The fluent string operations were introduced back in the release of Laravel 7 which offered a more object-oriented, fluent string manipulation library built on top of Illuminate\Support\Str
functions. To use this fluent API, you’d need to use the Illuminate\Support\Str::of
method which creates a fluent Illuminate\Support\Stringable
object.
Retry operations with high probability of failure in Laravel
January 24, 2021 — There are certain operations that can have a high probability of failure. For instance, sending a request to a third-party API. You’re not sure whether it will work every time flawlessly because it’s not in your control. If the API endpoint you’re hitting is not responding, you might end up with an exception straight away.
The query builder's sole() method to validate multiple records in Laravel 8.x
January 21, 2021 — With the latest release minor of Laravel, i.e. v8.23.0, a really interesting method has been introduced in Laravel’s query builder for situation where you want to get the only record for the matching criteria. But if there are more records for this criteria, there should be some sort of exception.
A little known artisan command that can inspire you
January 19, 2021 — While working on your codebase, be it developing features for your application or fixing bugs, we all tend to get a little bit demotivated sometimes in the middle of those sessions. Because after all, we are all humans and we all need some kind of inspiration every now and then.
How to prevent overlapping of jobs in Laravel
January 18, 2021 — When you are using Laravel queues, you might bump into the situation where you want to prevent overlapping of jobs that handles sensitive information. This could be to provide data integrity of important information such as the user’s wallet balance.
Artisan command to use model instance in controller actions in Laravel
January 11, 2021 — Here’s a little tip about the artisan command that generates the controller. So, if you’ve used the make:controller
command with the --resource
option, it will generate controllers with create, read, update, and delete (“CRUD”) actions in them.
Aliasing polymorphic types in Laravel's Eloquent
December 30, 2020 — When working with polymorphic relationships in Laravel’s Eloquent, it’s important to specify the “type” of the related model. You can do this by using morphOne
, morphMany
, and morphToMany
methods.
List scheduled commands in CLI in Laravel 8.x
December 16, 2020 — Sometimes, it would be convenient if you get details regarding things right in your terminal. Take for instance, all your scheduled commands that you have defined in your application’s App\Console\Kernel
class’ schedule
method like so.
Monitor a Laravel App with Scout APM (Sponsor)
December 15, 2020 — There is no denying the popularity of PHP. It has been a constant force in the web development world since its release in 1995. And now, thanks to Laravel, it is still going as strong as ever!
Delaying notifications channel-wise in Laravel 8.x
December 14, 2020 — Up until now, if you would need to delay notifications, you could do it by chaining the delay
method onto your notification instantiation like so.
Get up and running with Laravel blazing fast using Sail
December 9, 2020 — Imagine you just bought a new computer and the next thing you want to do is create a brand new Laravel application in your brand new machine.
Execute code outside of transaction only when it commits in Laravel 8.x
December 3, 2020 — Sometimes, there might be a case where you would want some of the code that lies outside of the transaction to be executed only when the corresponding transaction commits successfully and if in any case, it’s a rollback, that code shouldn’t be executed.
Artisan command to connect to the database in CLI in Laravel 8.x
November 25, 2020 — Laravel keeps getting better on each of its major releases. But sometimes, it’s the minor and patch releases that take the cake by introducing some lesser-noticed features.
Throttling submission of form in Laravel
November 22, 2020 — You might face a scenario where you’d want to restrict a user from submitting a form within a certain time limit. i.e to prevent spamming by users.
Monitor logs in Laravel Telescope in production environment
November 18, 2020 — The Laravel Telescope package is great for debugging your application when you’re working on your application in the local
environment. It provides insight into the requests coming into your application, exceptions, log entries, database queries, queued jobs, mail, notifications, cache operations, scheduled tasks, variable dumps, and various other things in this beautiful interface.
Using MySQL explain for queries in Laravel 8.x
November 16, 2020 — MySQL’s EXPLAIN statement is a handy tool if you want to take a quick glance over queries and to make out what’s wrong with them. Essentially, EXPLAIN
is used to obtain a query execution plan (that is, an explanation of how MySQL would execute a query).
Simple and lightweight scaffolding using Breeze in Laravel 8
November 11, 2020 — When Laravel 8 released, It came with a lot of new features & improvements but along with it, the Laravel team has also introduced Jetstream for application scaffolding which comes with all the bells and whistles in-built such as login, registration, email verification, two-factor authentication, session management, API support via Laravel Sanctum, and optional team management.
My first PR in laravel/framework that got merged!
November 9, 2020 — Alright! So, my first PR in laravel/framework has got merged and I’m on cloud 9 right now. I’m not kidding!
Loop over and include Blade views simultaneously using @each in Laravel
November 6, 2020 — Sometimes, there comes a scenario where you want to loop over a collection or array and include Blade views based on the iteration of that collection/array. You can use @foreach
and @include
for this purpose but there’s a handy way using which you can simplify this process.
Generate temporary URLs of AWS S3 files in Laravel
November 2, 2020 — Sometimes, all you want to do is generate temporary URLs for files that you have stored on your AWS S3 bucket. For instance, you would want to use this to prevent hotlinking of images.
Custom Eloquent collections to make queries more readable in Laravel
October 23, 2020 — If you’ve worked with Laravel, you might be aware of the fact that all the multi-result sets returned by Eloquent are instances of the Illuminate\Database\Eloquent\Collection
object. So, for instance, if you have a User
model, you can get all the users like so.
Insert or update multiple records using upsert in Laravel 8.x
October 20, 2020 — It would be useful sometimes when you’re not sure if you want to insert or update records and you’d let the system decide that. Laravel comes with one such feature that lets you do just that.
How to use .env values in Laravel Envoy
October 14, 2020 — Laravel Envoy is a great tool if you want to create deployment flow for your application or even something as small as writing a script to pull the latest code and deploy the application right away.
Binding additional information to views using composers in Laravel
October 12, 2020 — You know if you want to pass data to the views, you can do it while defining routes or from controllers like so.
Extending Validator facade for custom validation rules in Laravel
October 5, 2020 — In one of my articles, I’ve explained how you can extend class behavior using macros in Laravel.
Resolving dependencies conditionally using service container in Laravel
October 3, 2020 — One of the standard ways to resolve dependencies in Laravel is by using service container. Essentially, if you want to inject something which can be swappable anytime, you can do this by “biding” that into the service container.
Laravel Ecosystem Jargon
September 24, 2020 — Laravel, as a framework, has grown slowly but strongly since its inception and so is its ecosystem. The ecosystem here is all the packages/products that are built by the Laravel team which revolves around the original Laravel framework. This includes open-source packages and premium/paid products.
Catchable queued closures in Laravel 8
September 23, 2020 — One of the handiest features of Laravel is the ability to dispatch Closures to queues. This is because you don’t always need to create a job class for simple tasks such as sending emails.
How to use Laravel 7.x model factories in Laravel 8
September 18, 2020 — Laravel 8’s class-based model factories are great and I’ve written an entire article about what they are and how they are more feature-rich and useful than the traditional factories that we used to write prior to Laravel 8.
How to use Laravel 7 style controller route definitions in Laravel 8
September 16, 2020 — One of the most prominent changes in Laravel 8 is the (kind of) new way of defining controller routes. Before Laravel 8, if you wanted to define a route, you could do it like so.
New RateLimiter facade for defining named rate limiters in Laravel 8
September 14, 2020 — In the previous versions of Laravel, up to 7.x, when you wanted to rate limit certain routes, you could do it by assigning the throttle
middleware to the route or group of routes like so.
Class based model factories in Laravel 8
September 12, 2020 — The model factories in Laravel are a great way of seeding some fake data in the database for testing purposes which I’ve discussed in this article. While the previous implementation was great, Laravel 8 has given model factories a major overhaul and it makes them even better!
Access application in maintenance mode using a secret token in Laravel 8
September 11, 2020 — Apart from adding support for customizable maintenance mode views, Laravel 8 has also simplified the process of accessing the Laravel application in the maintenance mode.
Personalized maintenance mode views in Laravel 8
September 10, 2020 — When you put your Laravel application on maintenance mode using the php artisan down
command, the default view for the same looks like following.
Dynamic blade components in Laravel 8
September 9, 2020 — With the release of Laravel 8, you can now render Blade components dynamically using a built-in component called dynamic-component
.
Re-usable Blade components for Laravel projects using Blade UI Kit
September 3, 2020 — Recently, a prominent member of Laravel community, Dries Vints, has pre-released a pretty exciting open-source project called Blade UI Kit.
Refactor related macros to classes using Mixins in Laravel
September 1, 2020 — In one of my articles, I’ve described how you can add different behavior to some of the classes in Laravel using macros. To give you a primer, Laravel ships with this trait called Illuminate\Support\Traits\Macroable using which you can add additional methods to the class in hand (which is using the Macroable
trait) at run time.
Using simple yet effective caching for Laravel queries
August 26, 2020 — You know it’s always a good idea to have something at your disposal using which you can improve the performance of your applications. When it comes to web applications, one of the many things that power them is database queries and that’s why it’s no surprise that you may want to optimize those and make your application a little faster!
Define relationships outside of Eloquent models in Laravel
August 24, 2020 — You might be aware of the typical way of defining model relationships in Laravel Eloquent. i.e inside of the models itself.
Fetch count of records for children relationships in Laravel Eloquent
August 20, 2020 — There comes a time when you want to fetch the number of records for a child relationship along with the main Eloquent query.
Insert mass database records using model factories in Laravel
August 17, 2020 — One of the many ways using which you can insert records (or seed your database) is by using the seeder classes which extend a base class called Illuminate\Database\Seeder
in Laravel.
How to group where constraints in Laravel Eloquent
August 10, 2020 — When writing MySQL queries, if there are more than two where conditions, you’d want to group certain constraints/conditions to avoid unexpected behavior. For instance, check the following query.
Set default value for attributes in components using @props directive in Laravel
August 8, 2020 — As I described in this article on how you can create anonymous components in Laravel, we can create an <x-alert>
component with the following content.
Check for the application environment in Laravel views
August 5, 2020 — Often you’d come across a scenario where you’d like to check the application environment and based on that you’d like to render things.
Creating your own custom conditional directives in Laravel Blade
July 31, 2020 — Laravel’s Blade template engine is great and ever-evolving. There are some features in Blade, which if used appropriately, can make your codebase look more organized and recognizable.
Check if the specific service provider is loaded or not in Laravel
July 20, 2020 — Sometimes, you want to load some stuff based on the fact that the certain service provider is loaded in the providers
array of config/app.php
or not.
Tracking model attribute changes in Laravel
June 18, 2020 — Sometimes, it’s useful to know if somethig has been changed in the model since it’s been loaded. For instance, you would want to check if the is_published
attribute of the Post
model is set or not before publishing the post further.
Find the extension of files without extension in Laravel
June 11, 2020 — It’s helpful sometimes when you have a file and it doesn’t have extension attached to it but you want to know the extension of the file regardless.
Conditionally validate request fields in Laravel
May 28, 2020 — The usual way of validating request attributes in Laravel is by making Illuminate\Support\Facades\Validator
instance with your static rules that never change like so.
Validating Laravel requests using rule objects
May 20, 2020 — Laravel comes with a multitude of ways to validate request parameters. For instance, you could use Illuminate\Http\Request
’s validate method where you can specify all the fields that you would want to get validated inside controller’s action. You can do it like so.
How to pull a composer package in a Laravel project locally
May 7, 2020 — Lately, if you’ve been working on some functionality and you want to extract it as a Laravel package, you’d like to first test it locally. And if everything is well and good, you’d then publish it to the packagist.org.
Using custom class as a Facade in Laravel
April 29, 2020 — Facades, in Laravel, is basically a way of using Laravel’s classes without injecting them into the constructor of the class in which you want to use them.
Create your own custom Blade directive in Laravel
April 27, 2020 — Laravel Blade comes with many in-built directives such as @section
, @yield
, @parent
, @json
and several others, all of which have a certain purpose attached to them.
Auto discovery of events in Laravel
April 26, 2020 — In this article, I’ve written about how to use event subscribers or observer pattern in Laravel.
Listen to multiple events in a single class in Laravel
April 24, 2020 — The Observer design pattern is one of the twenty-three well-known “Gang of Four” design patterns that describe how to solve recurring design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test, and reuse.
Using different mail drivers dynamically in Laravel 7.x
April 23, 2020 — Sending emails in Laravel is a breeze. All you have to do is, configure your default mail service in config/mail.php
and it’s related configuration in config/services.php
file.
Named slots in Blade components in Laravel 7.x
April 14, 2020 — The new Blade components in Laravel 7 are great. They provide an easy way of defining blade components in a Vue-like tag aliases. One of the nice features of Blade components are slots.
Merge attributes in blade components in Laravel 7.x
April 7, 2020 — Blade component tags are a useful additions to the latest version of Laravel i.e. version 7. In Laravel 7, Blade components have been overhauled to allow tag based rendering, attribute management, component classes, inline view components, and more.
Reordering the sort order on queries in Laravel 7.x
April 2, 2020 — Often times, there comes a sceanrio where you’d want to alter the column through which you’ve setup your query to be sorted from. So, for instance, you’ve the following query.
Custom validation rules and messages in Laravel form requests
March 18, 2020 — If you want to validate request fields in Laravel, you could use Illuminate\Http\Request
’s validate method where you can specify all the fields that you would want to get validated inside controller’s action. You can do it like so.
Customizable artisan stubs in Laravel 7
March 12, 2020 — Artisan commands in Laravel are truly a blessing. I mean you could create just about any files be it controllers, models, middleware, provider by knocking a simple command from the CLI. For instance, if you want to create a model named Post
you could just fire the following command…
Fluent string operations in Laravel 7
March 10, 2020 — Laravel 7 has been a major version that’s been released last week and it comes with the host of features and improvements to the Laravel framework. One of the improvements being the new fluent string operations API. The goal of these API is to provide more flexibility and readablity to the regular string operations in Laravel by chaining array of string manipulation methods.
Route model bindings using custom columns in Laravel 7
March 5, 2020 — I’ve discussed about Route Model Bindings of Laravel in length in this article previously. If you’re not aware about the feature, I’d recommend you check that article first and come back here again.
Using whereNull and whereNotNull in Eloquent Collection in Laravel
February 26, 2020 — Working with Laravel Eloquent, we always had this ability to check null
fields when builing queries on models. For instance, if you want to check if email_verified_at
field is null
or not, you’d check it like so.
Convert request parameters to boolean in Laravel
February 16, 2020 — Sometimes, you might want to convert some of the request parameters to boolean. For instance, take a checkbox field. Unless and until, it hasn’t been checked it won’t be passed through to the request. In such a case, it would be beneficial to convert such inputs to boolean.
Add view within another view in Blade Laravel
February 6, 2020 — Sometimes, all you need to do is to add a Blade view into an another view. For instance, when you want to add JavaScript and CSS files as a separate Blade files which will contain the related content respectively. So, maybe you’ve a JavaScript blade file called view-js.blade.php
which wraps the JS code within <script>
tag and a CSS blade file called view-css.blade.php
which wraps the CSS code within <style>
tag. And all you want to do is add these to an another blade file called view-show.blade.php
.
Global view data for all actions in Laravel Blade
January 30, 2020 — Laravel’s Blade is a great templating system that blends with Laravel’s ecosystem very well. Setting some data to the view is a breeze and rendering those data into the template is ever so easy. For instance, if you would like to share some data from a controller’s action to a view, you’d do like so.
Add additional attributes in request in Laravel
January 29, 2020 — Sometimes, you might want to attach additional attributes to the original request that has made to the Laravel application. For instance, you want to put your own check in the middleware to see if the user is permitted to access the page or not, and pass that “check” by attaching it as an additional attribute to the request.
Identifying even and odd iterations in Laravel Blade
January 23, 2020 — When designing UI elements such as zebra strips in the tables, you’d need to identify if the loop iteration is even or odd and based on that you’d set the backgroud color of the row.
Authenticating certain controller methods in Laravel
January 22, 2020 — There are basically two ways of using the auth
middleware to authenticate the routes in Laravel.
Check unless condition in custom if blade directive in Laravel
January 20, 2020 — Laravel’s Blade::if()
method already comes with the following directives in order to check various conditions in blade template files.
Using objects as arrays (with a real world example) in PHP
January 15, 2020 — Sometimes, it’s convenient when you could get to access class objects as arrays. For instance, the time when one of the class properties is of type array and you want to manipulate it just like you’d do with an array without exposing it during object creation. I’ve included a real world example of where this could be useful, at the end of the article. So, read on!
Validating dependent attributes in Laravel request
January 9, 2020 — There comes a scenario in your app where there are some fields in your form that are dependent on an another field’s state.
Refactor eloquent queries using higher order messages in Laravel
December 12, 2019 — The best thing about working with Laravel is finding an alternate way to do same old boring stuff every now and then. I came across something called as “Higher Order Messages” while working with Eloquent recently. The feature has been in Laravel since its v5.4.
Attach, detach and sync many-to-many relationships in Laravel
December 1, 2019 — There exists four types of relationship associated between models/entities. And they are: One To One, One To Many, Many To One and Many To Many. We’re specifically going to talk about Many To Many relationship and most importantly attach
, detach
and sync
helper methods that are provided in Laravel in this article.
Drop tables, types and views using wipe artisan command in Laravel 6
November 6, 2019 — If you’re looking for a quick way to drop all the tables, their types and views and if you’re using Laravel 6.x, you can use this little artisan command called db:wipe
in order to do the same.
Extending class behaviour in Laravel using Macros
November 2, 2019 — In this article, I’m going to discuss about the feature in Laravel using which you can extend the functionality of certain Laravel’s core classes without even touching the original codebase. Or in other words, adding methods to the class dynamically.
Adding password confirmation on certain routes in Laravel
October 9, 2019 — If you’ve used some well creafted web application, such as GitHub for instance, you might’ve noticed that upon saving sensitive information such as settings or payment details, it asks for the password confirmation before performing the action. This adds the extra layer of security and certainly a nice-to-have feature.
How to utilize Capsule to use Eloquent ORM outside Laravel
September 11, 2019 — If you love the Laravel as a framework or more specifically its Eloquent ORM like I do then there’s a great chance that you’d like to use this great ORM in your non-Laravel PHP apps as well. And the good news is it’s rather easier than you might think. Laravel provides a standalone pacakge called Capsule which you can use in your own project. It’s a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style ORM, and schema builder. It currently supports MySQL, Postgres, SQL Server, and SQLite.
Using Lazy Collections on memory-hungry operations in Laravel 6
September 4, 2019 — Laravel team has recently released v6.0
of the framework and with this they have added a bunch of exciting new features. Among which, I’m going to talk about Lazy Collections in this article. In Laravel, Illuminate\Support\Collection
class provides a fluent, convenient wrapper for working with arrays of data. In face, all the Eloquent queries are always returned as Collection
instances. LazyCollection
essentially extends the features of the Collection
class. Let’s talk about them in detail.
Process model records in chunks in Laravel
August 27, 2019 — In this tweet, Freek Van der Herten explains how to process chunk of records from a model instead of loading all of them at a time which can help using less memory. Learn more about it in the article.
Rate limit route requests in Laravel
August 26, 2019 — As backend developers, to make our web application full proof we need to make sure our application is running as efficiently as possible all the time. Otherwise, everyone using your database will suffer from slow performance. API limiting, which is also known as rate limiting, is an essential component of Internet security, as DoS attacks can tank a server with unlimited API requests.
Understanding Constructor and Method dependency injection in Laravel
August 3, 2019 — To understand, how dependency injection works in Laravel, let’s just get to know what dependency injection actually is, in software engineering.
Serialize Closures in PHP using this neat package
Fetch results based on the existence of the relationship in Laravel Eloquoent
July 12, 2019 — If you want to check if the eloquoent model has certain relationship or not and fetch the results accordingly while querying upon it, you can do this by two approaches in the Laravel Eloquent.
Conditional attributes and relationships in Laravel Resources
July 6, 2019 — When you’re building an Laravel application which uses APIs at some point, it’s no brainer to use Laravel’s resource classes as it provides the transformation layer that sits between your Eloquent models and the JSON responses that are actually returned to your application’s users.
Re-using query constraints in Laravel Eloquent - Global vs. Local scopes
June 16, 2019 — Laravel’s Eloquent ORM comes with this unique set of features called “Scopes” which can be used to re-use some of the query constraints onto all the queries of a certain model. This can be useful to minimize the code while writing the query and is an easy way to make sure every query for a given model receives certain constraints.
Logout from every devices except the currently logged in one in Laravel
May 5, 2019 — Every robust web app has this feature where you’re provided with a setting through which you can choose to logout from all the devices you’ve been logged in from previously, except the current one. This is certainly a nice security feature that you can provide to your user without them even asking for it and if your app is built on top of Laravel 5.6, this comes out-of-the-box.
Laravel Route Model Bindings - Implicit Vs. Explicit Binding
April 29, 2019 — There’s this neat feature in Laravel where you can validate model IDs that have been injected into the route by injecting model instances directly at route level.
Attribute casting in Laravel Eloquent
April 15, 2019 — Laravel’s Eloquent is without a doubt a great ORM exists right now. It has some of the features which makes it ahead of its competitions. One such feature the ORM provides is called “Attribute casting”.
JavaScript functions' implementation inspired by PHP and Laravel
March 29, 2019 — A sometime ago I tried my hands on implementing some of the PHP’s native functions in native JavaScript. The result is quite interesting list of JavaScript functions you’ve never asked about.
Implement Invite-only registrations using Laravel's signed URLs
March 28, 2019 — There comes a time when you want URLs which are public but still you want some kind of authentication onto the same. For instance, you’d want such kind of URLs to enable invite-only registrations for your applications, where you’d send a URL to the user which that specific person only can access and register. In such scenarios, signed URLs can come in handy which are the special kind of URLs that have a “signature” hash appended to the query string to verify that the URL has not been modified since it was created.
Fetching dynamic attributes for models on-the-fly in Laravel
March 26, 2019 — There exist this neat feature in Laravel using which you can add attributes in the models that do not have a respective column in your database.
Packages to make your Laravel development experience awesome.
February 9, 2019 — While developing applications(not necessarily with Laravel), you come across the situation where you need to implement certain functionality. In such cases you shouldn’t want to reinvent the wheel if the functionality is been implemented by someone as a package, accepted well by the community and is ready to be consumed. It’s a no-brainer. I use to follow the same approach and today in this article, I’m going to list out some of my favorite Laravel packages which have made my experience with development in Laravel delicious.
Build your own Laravel artisan commands for your project
January 9, 2019 — When working on a project, there comes a time when you need to automate certain tasks. In such cases, it is better to use a CLI tool which can be run from the command prompt because using a web APIs for certain tasks is cumbersome.
Why you should use Laravel Queues
December 21, 2018 — There comes times when you wouldn’t want your end users staring at white screens or that intimidating loaders for a long time. For instance when user registers to your site, you must have configured your website to send a welcome email or a confirmation email upon registering. So, that operation should be snappy and for that purpose you’d actually want to reduce the amount of time your app takes while sending the email to the user. Laravel Queues comes to the recue for achieving such kind of time consuming tasks.
Laravel - Accessors & Mutators
August 23, 2017 — Accessors and mutators allow you to format Eloquent attribute values when you retrieve or set them on model instances. I’ll explain how you can you use them into your app.
Laravel Eager Loading - load() Vs. with()
August 17, 2017 — Today, while working with one of my projects(which is built on top Laravel) I bumped into the situation where I needed to get associated model’s data for one of the models. So here, I had two approaches in Laravel to accomplish this which are basically called Eager Loading: