Reverse Engineering in Mysql Workbench


It’s such a great day in 2016, I pushed myself to focus on developing “something that matters”.  I still have two papers for final exam as I’m currently further study in Bachelor Degree of Software Engineering in one of Public University in Malaysia.

As final year student, I’m required to develop a Final Year Project. I decided to develop a mobile app with PHP as the backend server.

Previously, I use MySql Workbench to draft my database design. I’m using Laravel as the backend server for my mobile app.  After doing the migration in Laravel,  I realize that I should redesign my database.

After all migration files migrated  to MySQL database, I need to write the model relationship in Laravel. A lot of changes in relationship design from my draft database and my current database after migration.

To generate a new design view in MySql Workbench from my current database here is the step in short.

  1. Export to an SQL file for the database from PhpMyAdmin
  2. Open MySQL Workbench, go to menu,
    Database > Reverse Engineer
  3. Import the SQL file and follow instruction on workbench’s wizard
    Reverse Engineer in MySQL Workbench
  4. After completing the wizard, new Workbench view will generate based on your SQL file. The view design is looking good and easy to read as workbench design the arrangement for you.

Laravel Count and GroupBy Field Query

I have been busy developing an e-commerce platform from zero to fulfill this semester project for Web Programming Course.

I need to select 5 the most popular product based on customer order. Customer order is stored in order_details table. To make a that query in laravel, try this:

Based on code snippet above, it will return 5 product_id as the most ordered product.

p/s: my 2016 mission, be a morning person!

Code Snippet: WordPress Nginx Configuration File With SSL Enable

WordPress is running smooth with Nginx. I have a server with DigitalOcean and currently use WordPress with Nginx. Here is the code snippet for Nginx configuration with SSL enable.

To use this code snippet, you are required to have a valid SSL installed on your server. After that replace on the configuration code above with your own domain.


PHPMyAdmin: Drop a Foreign Key

Drop the foreign key relation before drop the index. Have a look at the output of:


It will show the internal name of the foreign key constraint which is use during the table set up process. Drop this foreign key with:

ALTER TABLE table_name DROP FOREIGN KEY key_name

before we can drop the index on the foreign key field. InnoDB relies on indexes on all key columns in a foreign key constraint.

Installing Laravel Debugbar For Easy Debugging Laravel 5

The Laravel Debugbar by Barry vd. Heuvel is a package that allows you to quickly and easily keep tabs on your application during development. With a simple installation and powerful features, theDebugbar package is one of the cornerstone packages for Laravel.


In your Laravel 5 project require the package:

composer require barryvdh/laravel-debugbar

Next open config/app.php and inside the ‘providers’ array add:


If you want to use the facade to log messages, add this to your facades in app.php:

‘Debugbar’ => Barryvdh\Debugbar\Facade::class,

Now as long as your app is in debug mode the bar will already be loading showing some nice stats about the page you are viewing.

WordPress Varnish Cache Age 0

Varnish with cache age 0 means that varnish did not serve the content from cache.

To solve this, edit your sudo nano /etc/varnish/default.vcl

paste this in that file.

After that restart varnish service,

sudo service varnish restart

you may check your varnish status here

How to get the original IP address in Apache2 behind Varnish

I’m having Varnish as a frontend and then running Apache through reverse proxy. The Apache logs become full of just a single IP address, the accesses from the Varnish server – usually if you are running both on the same server.

No more GeoIP decisions on the backend or any other feature by remote address.

But we know that Varnish passes along the original client IP address on a HTTP header named X-Forwarded-For to the backend server. It would be awesome if Apache could deal with that,

Fortunately there is already a module that injects the IP on a special header to the HTTP request to Apache: mod_remoteip

  1. Install mod_remoteip
  2. Enable the module
  3. Edit your apache2 configuration file
  4. Add this line at the end of the file
  5. Restart Apache service

You should now get the client’s real IP address instead of varnish IP address.


WordPress: Change Contus Video Gallery Player To Recent Video

Contus Video Gallery is a super-awesome video gallery plugin for wordpress. Read more here.

By default, Contus video gallery will show recent featured video in homepage video player. Instead of recent featured video, we will change it to the most recent video from all categories. (The most recent upload video)

To show the latest video in the home page player, go to file path ../wp-content/plugins/contus-video-gallery/front/models/videohome.php

In this file finds the function get_featuredvideodata() and find the below query

and replace with the below query

documenting to blog post from original source

[Snippet] WordPress: Hide Post By Author From Admin Post List

There is a situation where we need to hide a post written by user A from user B while both of them has same role as “Editor”.

Let’s say we have two user as follow:

UserA with ID 17 and roles Editor
UserB with ID 9 and roles Editor

We need to hide all post by UserB so UserA cannot see it in WordPress Post List (admin page).

Code snippet below may help you to do this in easily.

Modified as you want 😀

[Snippet] Get All Post From Blogger In JSON Format

The time during this blog post written, Blogger API v3 is still not available to use by public. To use the API, you need to fill in the Google Form and request for an access.

I try to get all of my post from Blogger blog yesterday. I found that we can use JSON request to get all post from a blog in blogger without any restriction.

The following is a code snippet that I use to get all post from my blog in blogger.

As you can see in example above, I’m trying to get 500 recent post from  Blogger Developers Network. Feel free to review and update the code above as what you need. 🙂

Have a nice day!