All you need to know about Pivot Tables


In this post, I am going to talk about many-to-many relationships and Pivot Tables. You heard about it, perhaps used it but you still don’t fully understand the concept, then keep on ready this post.  Pivot tables are very helpful when designing  database structure but can be difficult to understand sometimes. Pivot tables are intermediate tables that facilitates relationships between two main tables and even within one table.

When exactly you need Pivot Table

First of all, let’s clear our understanding of scenarios where Pivot Table can help us.  As I said  it provides many-to-many relationship between two tables, let’s look at some examples when exactly one need many-to-many-relationship and Pivot Table.

Categories-Posts Example

If you have used WordPress, you know that you can assign multiple categories to a post. So here, a post can reside in multiple categories and a category can have multiple posts in it. Technically

Post -> Belongs To Many -> Categories

Categories -> Belongs To Many -> Posts

that’s a very basic scenario where you will need pivot table. Here’s what the table structure will look like. Continue reading

Case Study – How we managed to drastically improve API Performance

Recently we got the chance to look into the load speed issue for one of the project, we are required to improve API performance for a listing screen. The project was built in AngularJS and API being created in Laravel.

Two of the major listing pages of the application has become hell slow with time, 10 seconds to be exact. The application itself is quite big and is going under heavy development for last 2 years. As it’s a SAAS based so data is growing rapidly. In this article, we are going to present the steps we took to improve API performance and how we managed to reduce the Load time of the Laravel API for listing screens which were taking more than 8 sec to just a sec.

Database Indexing

This is one of the most common mistakes, especially with those teams which don’t have a special database administrator assigned in the project to manage and create the database, and the task of creating the migration is left for the developer.  While creating the migrations for the database, or schema in general, developers tend to ignore creating indexes and they generally get away with it for quite long, Until your application is live and data grows to a point where you start feeling the performance issues, those long spinning loaders drops a hint. Continue reading

Laravel Eloquent Tips and Tricks

Laravel Eloquent Tips and Tricks

Here is the list of some of the useful Laravel Eloquent Tips and Tricks which are usually ignored by developers and not used as much as these should be.

1.) Expressive where syntax

$products = Product::where('category' , 3);

you can do this instead

$product = Product::whereCategory(3);

just append column name in plural case after where

2.) Date filtering

$q->whereDate('created_at', date('Y-m-d'));
$q->whereDay('created_at', date('d'));
$q->whereMonth('created_at', date('m'));
$q->whereYear('created_at', date('Y'));

Continue reading

Quick Tip: PHP MySql Pagination with Random Ordering

I recently got to work a site which was more like a directory. One of main trick there was to show random advertiser on the site so that each advertiser get’s some chance for displaying on sites front page. That was actually easy until this has to go with pagination. Back then I didn’t even knew if there’s any way to achieve mysql pagination with random ordering.

Problem is, you show some random advertisers on 1st page but on second page you must see another set of random advertisers (excluding what you already seen on 1st page) and so on. you see where’s it’s going?

Mysql Rand(seed) function to rescue

SELECT * FROM your_table ORDER BY RAND(351) LIMIT 10, 10;

Continue reading

Some Useful PHP functions and features

Some useful but lesser known PHP functions

In this article I am going to cover up some lesser known but Useful PHP Functions which offers some great functionalities. Not all but many of these are usually re coded. Here’s the list of such Useful PHP Functions and features that I have compiled over time. These might also come in handy for you in your day to day coding.

  1. Converting Newline to Break – nltobr
  2. Placeholder replacement – strtr
  3. Die
  4. Parsing Url – parse_url
  5. glob
  6. Magic Constants
  7. str_word_count()
  8. Serialization – json_encode & json_decode

Continue reading

Add links to WordPress Toolbar

By default  WordPress displays a toolbar on top of all pages to logged in users. In this article, we will show you how to add links to WordPress toolbar.

Why You Need to Add Links to WordPress Toolbar?

By default the toolbar shows useful links to WordPress admin side, allowing users to quickly access different sections of their website. For example, links to an external resource, service, or website. These links can be added to WordPress toolbar as shortcut links allowing you and your users easy access to those locations directly from your site or the admin side.
Continue reading

Custom List Table Page Tutorial- WordPress


Ok, before I go ahead with the article let’s clearly know what it’s about and what we are going to create in this article.

In This Article, we are going to create a List Table Page in WordPress Administrator interface.

What is a List Table Page?

A List Table Page is page which list down records from database in table format and along with it allows us to perform some action on the records e.g. filtering and searching. The page which you see when you click on ‘All Posts’ or ‘All Pages’ are example of List Table.

Continue reading

Quick Tip: Console.log Issues in IE (IE8 & IE9)

Me and team has already spent lot of restless nights and moments in frustration and believe me, do read it out unless you already know what this tip is about, it can save you some serious amount of  time.

Tom – The great Tester: It’s not working in IE
Allen – The frustrated developer: What can I do it’s working here at my PC come and check.

Allen has no idea how it’s working on his machine. It’s because he always has developer toolbar opened 🙂
Continue reading

NATIVE vs. WEB vs. HYBRID Mobile Apps


A lot of people still confuses among these three types of apps. This might be of some help.

When you consider developing a new mobile app, you primarily have three choices. You could build a native app using the tools and SDKs provided by the platform vendor. You could build a mobile-optimized website using standards-based technology like HTML and JavaScript. You could build a hybrid app that wraps a native shell around a WebView enabling you to build the content of your app using HTML and JavaScript.


Native apps will always provide the best experience on the given platform. That is simply because if you build a native app using the SDKs for the platform you are able to optimize for the platform and take advantage of everything the platform has to offer. For apps where the device is the primary factor (i.e. you want the best iPhone experience possible) or milliseconds matter, such as in high-polygon count games like CSR Racing or Galaxy of Fire 2, native development is the only choice. For apps like this you need to take advantage of everything the platform has to offer, from the GPU to the screen pixel depth.
Continue reading

Cross Client Email Templates – Practices and Resource


If you are a web developer you must have had a chance to write Email Templates which should work across all major email clients consistently. I too have fought that battle many times and I know it’s hard and frustrating to write and check Cross Client Email Templates.

This article is an attempt to help avoid the frustration one has to go through when designing Cross Client Email Templates. I’ll try to list down the DO’s and DON’Ts that we should adhere to when writing Email Templates for maximum compatibility across email clients. Also I’ll list down the common issues/bugs that are faced in Email Templates and their solutions.

  1. Use of table for layout
  2. Make sure to have a correct DOCTYPE Declaration
  3. Use of inline style
  4. Issue with empty cells
  5. White space issue with images
  6. Close every tag properly
  7. Properly using the background images
  8. Specify height, width and alt attribute with images
  9. Test test and test

Continue reading