Laravel Eloquent – Integrity constraint violation: 1452 foreign key constraint or General error: 1005

Are¬†you trying to set-up a foreign key constraint on one of your tables and you’re getting a 1452 error?

[Illuminate\Database\QueryException]
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

 

You might also get a General error: 1005

[PDOException]
  SQLSTATE[HY000]: General error: 1005 Can't create table `app`.`#sql-33d4_1a2` (errno: 150 "Foreign key constraint is incorrectly formed")

 

This is a MySql issue and not a Laravel one.

Continue reading Laravel Eloquent – Integrity constraint violation: 1452 foreign key constraint or General error: 1005

Build a PHP login system using Laravel 5

Laravel makes it super easy to build a login system because it has everything already built and configured for you, here is how to create a login system using Laravel 5.2

Lets create a new Laravel project using composer:

 composer create-project --prefer-dist laravel/laravel login 

To get the authentication up and running we need to do a few things but luckily Laravel makes the set-up a breeze.

Continue reading Build a PHP login system using Laravel 5