September, 24, 2019 . 1 min read

Understanding Autoload and Namespace in PHP

If you come across from procedural PHP programming, __autoload__ and __namespace__ kind of confusing naming for you. To make it easier, today, I will take a deep dive into understanding autoload and namespace in PHP. ## What is Autoloading? Autoloading is a mechanism where you can load all the required files in your project automatically....

Understanding Autoload and Namespace in PHP

September, 09, 2019 . 2 min read

Laravel increment column and Update Records

Today I saw a code where the programmer wants to update a laravel model at the same time, he wants to increment a column's value. Today, I will show you the easiest way how to increment column and update Laravel records. Just imagine that we have a table called `posts`, that's structure is like that- __posts__ ``` - id - title - body...

Laravel increment column and Update Records

September, 02, 2019 . 1 min read

laravel tests Invalid argument supplied for foreach()

If you faced the issue with laravel tests Invalid argument supplied for foreach(), this post might be helpful for you. Recently I was trying to test something, where I was facing this issue. I will write the code in details with the scenario, hope it will be helpful for you. ## Scenario I allow my user to create a __post__ where user can abl...

laravel tests Invalid argument supplied for foreach()

August, 30, 2019 . 3 min read

Ignition: A beautiful error page for Laravel Apps

In the local development, we see the Laravel error page a lot. Most probably the countless time in every day. You can do a beautiful representation of the error page, the will be more readable, eye-catching and nice to see. [Ignition](https://github.com/facade/ignition) brings a beautiful error page of your application. Let's see how we can integra...

Ignition: A beautiful error page for Laravel Apps

August, 30, 2019 . 2 min read

How to run a specific test in Laravel Dusk?

If you ever stuck how to run a specific test in Laravel Dusk instead of all the test, this post might help you. There are probably two ways to run a specific test in Laravel dusk, by the file location and by using `--filter` keyword. Let's dig into it. Once you install dusk, you will able to see the list of the command of dusk in the `php artis...

How to run a specific test in Laravel Dusk?

August, 30, 2019 . 1 min read

How to add unique email in Laravel Faker

Imagine that, you have a __UserFactory__ in laravel project where the email address is `unique`. In general, you can easily add generate an email with faker like this way- ```php <?php use Faker\Generator as Faker; $factory->define(App\User::class, function (Faker $faker) { return [ 'username' => $faker->name, 'ema...

How to add unique email in Laravel Faker

August, 27, 2019 . 4 min read

Laravel Pagination Vs Chunk

Have you ever put together Laravel Pagination and Chunk, then realize how it works? Are they same or there is a difference between them? If same, then what is the purpose of having two different options for achieving the same work, if not, then what are the fundamental difference between them. In this post, I will talk about it. Apparently, i...

Laravel Pagination Vs Chunk

August, 24, 2019 . 2 min read

Eager loading in Laravel query builder

Sometimes you need to write some query in laravel by using [Query Builder](https://laravel.com/docs/5.8/queries), at the same time you might need to use [Eager loading](https://laravel.com/docs/5.8/eloquent-relationships#eager-loading) the relationship. But unfortunately, eager loading and query builder does not fit together. So, in this scenario,...

Eager loading in Laravel query builder

August, 23, 2019 . 2 min read

Clean Architecture in PHP | Part 1

Suddenly I feel to improve my knowledge about Clean architecture in PHP. As of, I started reading some books, tutorials, and screencasts. There are lots of content around the internet. I plan to write my extractions that I have learned from those sources. Hopefully, it will be helpful for you. Today, I will share in what context clean PHP architect...

Clean Architecture in PHP | Part 1

August, 22, 2019 . 2 min read

How to use each function in Laravel

Laravel has a beautiful `each` method that can help you to process a lot of models. Consider that, you have thousands of models, so, don't load them all into memory, but chunk them. Laravel `each` function will help you to figure out in this issue. Let's see how to use each function in Laravel. ## What is exactly each method? According to th...

How to use each function in Laravel