programming

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 »

Using IF Condition Inside a query in Laravel

The task for me today was to filter the products as per their status i.e if they are published then their value would be 1 and if they are unpublished then their value would be 0. But I didn’t want to create three queries for them, one for each condition. Therefore, I used the if …

Using IF Condition Inside a query in Laravel Read More »

How to compare data in a relationship table with the main table without using more than one loop?

I had this problem where I had to get all the names from one table and get relation from another table and check if the relationship exists or not and if it exists, the checkbox must be checked. Let me clear the problem first. I need to show all the categories of the posts. So …

How to compare data in a relationship table with the main table without using more than one loop? Read More »

Checkboxes and the logic behind updating them

My task for the day was to build checkboxes of all the categories available for the posts. One post may have multiple categories. The first thing to do was to build a form where the multiple checkboxes are dynamically available and add them to the post-category relationship table (add only the id of both post …

Checkboxes and the logic behind updating them Read More »