Laravel Migration issues – Foreign Key not able to be assigned.

1. First issue, not using INNODB (using MYISAM by default). To fix this, each table will need to have this line

Schema::create(‘branches’, function (Blueprint $table) {

$table->engine = ‘InnoDB’;


2. MySQL Error 1215: Cannot add foreign key constraint

To debug this, run the following SQL against the DB.


2017-10-01 19:01:01 0x29fc Error in foreign key constraint of table amanah/#sql-b98_157:
foreign key (`brnch_id`) references `branches` (`brnch_id`) on delete cascade:
Cannot resolve table name close to:
(`brnch_id`) on delete cascade


This usually means the system was not able to find the TABLE mentioned .

Also this would mean the table is NOT YET BUILT when the assignment of Foreign key is done.

To fix this issue: Check the date and time of each migration file (for each table). The table referenced to have the foreign key MUST BE BUILT BEFORE. Therefore the filenames MUST BE IN ORDER.


Migrating: 2017_09_23_000000_create_users_table
Migrated: 2017_09_23_000000_create_users_table
Migrating: 2017_09_23_100000_create_password_resets_table
Migrated: 2017_09_23_100000_create_password_resets_table
Migrating: 2017_10_01_141720_create_branches_table
Migrated: 2017_10_01_141720_create_branches_table
Migrating: 2017_10_01_151153_create_mettingtypes_table
Migrated: 2017_10_01_151153_create_mettingtypes_table
Migrating: 2017_10_01_215348_create_reports_table
Migrated: 2017_10_01_215348_create_reports_table
Migrating: 2017_10_02_215258_create_meetings_table
Migrated: 2017_10_02_215258_create_meetings_table


Once that is fixed, MIGRATION TABLE NEEDS TO BE TRUNCATED (so that it will contain the updated filenames).



The code should  be as above.


The foreign key must be of the same type (unsigned integer) and length (10) – else it wont work.


Also, the foreign key (in the original/main table) must be added as INDEXED, or PRIMARY.



Laravel – column declaration $table->increments(‘loc_id’,true, false);

If you found something like this, this is an alternative way to declare $autoIncrement = false, $unsigned = false

$table->increments('type_id',true, false);
$table->unsignedInteger('location_id', false, false);

As found in the following file:


     * Create a new small integer (2-byte) column on the table.
     * @param  string  $column
     * @param  bool  $autoIncrement
     * @param  bool  $unsigned
     * @return \Illuminate\Support\Fluent
    public function smallInteger($column, $autoIncrement = false, $unsigned = false)
        return $this->addColumn('smallInteger', $column, compact('autoIncrement', 'unsigned'));


Peoplesoft SETID and Business Unit

Business Units
Business Units are logical units created within any organization for reporting purposes and don’t have any predetermined restrictions or requirements. This flexible structuring device enables you to actually define a higher level of reporting for your employees and group them according to functional or administrative tasks or for your business purposes.

One can define Business Units that reflect the specific functional needs of your internal human resources departments, or reflect the actual business structure of your enterprise. Your Business Units may be, for example, companies, agencies, subsidiaries, divisions, departments, or branch offices within your organization. Or, you may choose to have a single Business Unit represent your entire organization. It’s up to you and your unique business needs.

TableSets and SetIDs
Once you’ve established Business Units, you can define TableSets, or groups of tables, for your system-wide control tables, so that you can share the same code values among multiple Business Units within your enterprise. Conversely, the TableSet feature also enables you to limit access to specific data to only those users who need it, while maintaining all of your data on the same tables. The flexibility to share TableSets among Business Units enables you to centralize redundant information while you keep other information, such as Department and Job Codes, decentralized. You can use Business Units and TableSets to associate a Business Unit with employees in your enterprise and to specify how default values for currencies and country codes will behave throughout the HRMS system, based on either the user’s Permission List or the Business Unit that the system is referencing during a particular business process or activity.

Where a Business Unit organizes your company or your organization, SetIDs help you organize your data within the system. The HRMS system uses tables (Control Tables or Prompt Tables) that use a high-level key that enables you to identify and retrieve data from the system. A secondary high-level key, referred to as a SetID, has also been added on various tables. SetIDs are simply the labels used to identify a TableSet. Business Unit and SetID functionality in PeopleSoft also provides you with a higher business level for reporting purposes and other business data roll-up.

Laravel: issues encountered (1)


this is a headache – mainly because using localhost will cause the FRONT FACING path (public directory) is not the ROOT directory

For example:


Path: C:\wamp\www\myblog\public

This pose a problem when routing within the website


<form method="POST" action="/posts/{{ $postid->post_id }}/comments">
Route::post('/posts/{postid}/comments', 'CommentsController@Store')->name('storeComment');

<form method="POST" action="myblog/public/posts/{{ $postid->post_id }}/comments/">

<form method="POST" action="/myblog/public/posts/{{ $postid->post_id }}/comments/">

So we have to setup a local domain


C:\Windows\System32\drivers\etc myblog.lists.this              # x client host



<VirtualHost *:80>
	ServerName myblog.lists.this
	ServerAlias myblog.lists.this
	DocumentRoot C:/wamp/www/myblog/public
	<Directory  "c:/wamp/www/myblog/public">
		Options +Indexes +Includes +FollowSymLinks +MultiViews
		AllowOverride All
		Require local


Laravel App Model codes

This is the codes for the model



namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Post;
use Carbon\Carbon; //for timestampe

class PostController extends Controller
    public function Index() {

    return view('posts.index');


    public function Store() {

      // $current_time = Carbon::now()->toDateTimeString();
      // // echo $date->getTimestamp();
      // // $post = new App\Post; //Class 'App\Http\Controllers\App\Post' not found
      // $post = new \App\Post;
      // $post->title = request('thisTitle');
      // $post->content = request('thisContent');
      // $post->created_at = $current_time;
      // $post->save();

      // OR

      Post::create( request(  ['title','content'] ) );

    // dd(request()->all() );
    // dd(request('thisTitle') );
    // dd(request(['thisTitle','thisContent']) );
    // return redirect ('/myblog/public/posts'); //http://localhost/myblog/public/myblog/public/posts
    return redirect ('/posts');



GIT logs (1)

All the basic commands to use GIT

  1. Use CMDER
  2. Install GIT
git init / git clone
git status

git add --all
git add .

git branch <branchname> (git branch dev)
git checkout <branchname>
git checkout -b <newbranchname>

git commit -m "this is the commit message"
git commit (opens up text editor/vim)

git remote add origin remote repository URL
git remote add origin<githubAccount>/myblog.git
# Sets the new remote

git remote -v
# Verifies the new remote URL
Push the changes in your local repository to GitHub.

git push origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin


Good site to understand GIT


Peoplecode setting value to Null

Peoplecode setting value to Null


Always use space to assign a null value to a string.
e.g. &Test_Str = ” “;


Use 0 (zero) to assign a null value to a number.
e.g. &Test_Num = 0;


Always Use blank value to assign a null value to a date otherwise it will give you invalid date error if it is equated to null or space as string.
e.g. &Test_Date = “”;

Other Data Types

For other data types like record, rowset we can assign them to null so as to get accurate results from all() and none() functions by paasing them as parameter.
e.g. &Test_Rec = null;

Application Class Properties

We can not use all() or none() functions to check if any property of application class is set. For this we will need to check by equating it to null or blank or space or zero based on its type in a conditional statement.

Laravel Database Connection Config

it is in .env file

in C:\wamp\www\myblog

(the root of the site created by Laravel)



WAMP physical PATH vs Laravel PATH


Lets say the following is the path to WAMP.



is the path to localhost/<something>

To make something accessible on WAMP, use something like this

Path on WAMP: C:\wamp\www\libs\jquery-3.2.1.min.js
<script src=”/libs/jquery-3.2.1.min.js”></script>


Path to the project (called “blog2”):


Laravel will always reference the public folder in the project, therefore, put the css in the public directory (it is there by default)


And access it in the view script this way

<link href=”css/bootstrap.min.css” rel=”stylesheet”>

which Laravel will translate into: http://localhost/blog2/public/css/bootstrap.min.css