I had a strange problem with aws, mysql, laravel and angular.
I have a vagrant instance running locally with both of my applications and databases running on it.
I use angular in the interface, so when loading a view, angular makes a request to get a list of all the "goals" entered by the user. One of the goals is the goal of Status. it is either 0 or 1 stored as an integer in the mysql table.
angular checks to see if it has a value of 0 or 1 and displays another table cell depending on a result like
<th ng-if="goal.goalStatus === '0'"><p class="text-danger">In Progress</p></th>
<th ng-if="goal.goalStatus === '1'"><p class="text-success">Achieved</p></th>
in chrome dev tools, when I look at the response result for this request, I see that returnStatus is returned this way
"goalStatus":"0"
angular if .
, beanstalk, mysql rds, , dev tools Status,
"goalStatus":0
angular, ,
, , beanstalk , . , mysql, laravel - .
? laravel
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateGoalsTable extends Migration
{
public function up()
{
Schema::create('goals', function(Blueprint $table) {
$table->increments('id');
$table->integer('userId');
$table->string('title');
$table->string('goalDesc');
$table->integer('goalStatus')->nullable();
$table->integer('bodyGoalId')->nullable();
$table->integer('strengthGoalId')->nullable();
$table->integer('distanceGoalId')->nullable();
$table->timestamps();
});
}
public function down()
{
Schema::drop('goals');
}
}
<?php
class GoalsTableSeeder extends Seeder
{
public function run()
{
DB::table('goals')->truncate();
$now = date('Y-m-d H:i:s');
$goals = array(array(
'userId' => 1,
'title' => 'first goal title',
'goalDesc' => 'This should describe my goal in text form',
'goalStatus' => 0,
'bodyGoalId' => null,
'strengthGoalId' => null,
'distanceGoalId' => 1,
'created_at' => $now,
'updated_at' => $now),
array(
'userId' => 1,
'title' => 'strength goal title',
'goalDesc' => 'This should describe my strngth goal in text form',
'goalStatus' => 0,
'bodyGoalId' => null,
'strengthGoalId' => 1,
'distanceGoalId' => null,
'created_at' => $now,
'updated_at' => $now),
array(
'userId' => 1,
'title' => 'body goal title',
'goalDesc' => 'This should describe my body goal in text form',
'goalStatus' => 0,
'bodyGoalId' => 1,
'strengthGoalId' => null,
'distanceGoalId' => null,
'created_at' => $now,
'updated_at' => $now)
);
DB::table('goals')->insert($goals);
}
}