ankitsubedi

How to check if the result is empty for eloquent collection in Laravel?

A lot of times when coding we might encounter a problem where we have to check if the result we are getting has some data or not. But when we are working with eloquent results, even if it is empty, the function ’empty()’ holds false as well as ‘if($result)’ always holds true. So to find …

How to check if the result is empty for eloquent collection in Laravel? Read More »

Altering Table Through Migrations Laravel

It is a very difficult job to change the column name or type once it is migrated and has contents. In order to modify the column, we need to create another migration where we state the modifications. Let us create a migration first by using the following command Php artisan make:migration change_post_description_to_nullable_in_tbl_posts —table=tbl_posts This will …

Altering Table Through Migrations Laravel Read More »

Laravel Form Collective Select Tutorial

The select form is a bit complicated among other forms in Laravel collective. It is because we need to follow certain rules to make it work. First of all the code of the form looks like this Form::select(“postId”, $post, null, [‘class’ => ‘form-control’]); Let me explain the code first. We need to store the value …

Laravel Form Collective Select Tutorial Read More »

All about Migration Rollbacks

The examples are focused on how to roll back migrations on Laravel. This rolls back the last migrations Migration rollback according to steps. The below code will roll back the last two migrations. Change the steps to roll back accordingly. If you want to roll back as well as remigrate the last migrations To roll …

All about Migration Rollbacks Read More »

Using When Condition Inside a query in Laravel

Similar to the previous article I wrote about using the IF condition inside a query (Click Here for the link), I asked Reddit for the best way to handle the query in my previous article and I learned a bunch of ways where we can get the same solution. One of them using the when …

Using When Condition Inside a query in Laravel Read More »