Created API endpoints
This commit is contained in:
@@ -15,11 +15,19 @@ class CreateUsersTable extends Migration
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
|
||||
$table->string('username', 60);
|
||||
|
||||
$table->string('name', 100);
|
||||
|
||||
$table->string('email', 100)
|
||||
->unique();
|
||||
|
||||
$table->string('password', 41);
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCategoriesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
||||
$table->string('code', 10);
|
||||
|
||||
$table->string('name', 100);
|
||||
|
||||
$table->integer('creator_id')
|
||||
->unsigned()
|
||||
->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->softDeletes();
|
||||
|
||||
|
||||
$table->foreign('creator_id')
|
||||
->references('id')->on('users')
|
||||
->onDeletes('restrict')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('categories');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateQuestionnairesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('questionnaires', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
||||
$table->string('title', 100);
|
||||
|
||||
$table->text('description')
|
||||
->nullable();
|
||||
|
||||
$table->integer('creator_id')
|
||||
->unsigned();
|
||||
|
||||
$table->integer('category_id')
|
||||
->unsigned()
|
||||
->nullable();
|
||||
|
||||
$table->integer('reviewer_id')
|
||||
->unsigned()
|
||||
->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->timestamp('released_at')
|
||||
->nullable();
|
||||
|
||||
$table->timestamp('closed_at')
|
||||
->nullable();
|
||||
|
||||
$table->timestamp('reviewed_at')
|
||||
->nullable();
|
||||
|
||||
$table->softDeletes();
|
||||
|
||||
|
||||
$table->foreign('creator_id')
|
||||
->references('id')->on('users')
|
||||
->onDelete('restrict')
|
||||
->onUpdate('cascade');
|
||||
|
||||
$table->foreign('category_id')
|
||||
->references('id')->on('categories')
|
||||
->onDelete('restrict')
|
||||
->onUpdate('cascade');
|
||||
|
||||
$table->foreign('reviewer_id')
|
||||
->references('id')->on('users')
|
||||
->onDelete('restrict')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('questionnaires');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateSectionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('sections', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
||||
$table->integer('questionnaire_id')
|
||||
->unsigned();
|
||||
|
||||
$table->integer('creator_id')
|
||||
->unsigned();
|
||||
|
||||
$table->string('title', 100);
|
||||
|
||||
$table->text('description')
|
||||
->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->softDeletes();
|
||||
|
||||
|
||||
$table->foreign('questionnaire_id')
|
||||
->references('id')->on('questionnaires')
|
||||
->onDelete('restrict')
|
||||
->onUpdate('cascade');
|
||||
|
||||
$table->foreign('creator_id')
|
||||
->references('id')->on('users')
|
||||
->onDelete('restrict')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('sections');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateQuestionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('questions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
||||
$table->integer('section_id')
|
||||
->unsigned();
|
||||
|
||||
$table->integer('creator_id')
|
||||
->unsigned();
|
||||
|
||||
$table->integer('number');
|
||||
|
||||
$table->string('text', 300);
|
||||
|
||||
$table->text('description')
|
||||
->nullable();
|
||||
|
||||
$table->integer('expected_length')
|
||||
->nullable();
|
||||
|
||||
$table->enum('question_type', [
|
||||
'text',
|
||||
'choice',
|
||||
'multichoice',
|
||||
'numeric',
|
||||
'bool'
|
||||
])
|
||||
->default('text');
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->softDeletes();
|
||||
|
||||
|
||||
$table->foreign('section_id')
|
||||
->references('id')->on('sections')
|
||||
->onDelete('restrict')
|
||||
->onUpdate('cascade');
|
||||
|
||||
$table->foreign('creator_id')
|
||||
->references('id')->on('users')
|
||||
->onDelete('restrict')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('questions');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateQuestionchoicesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('questionchoices', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
||||
$table->integer('question_id')
|
||||
->unsigned();
|
||||
|
||||
$table->integer('creator_id')
|
||||
->unsigned()
|
||||
->nullable();
|
||||
|
||||
$table->integer('number');
|
||||
|
||||
$table->string('text', 300);
|
||||
|
||||
$table->text('description')
|
||||
->nullable();
|
||||
|
||||
$table->boolean('fillable')
|
||||
->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->softDeletes();
|
||||
|
||||
|
||||
$table->foreign('question_id')
|
||||
->references('id')->on('questions')
|
||||
->onDelete('restrict')
|
||||
->onUpdate('cascade');
|
||||
|
||||
$table->foreign('creator_id')
|
||||
->references('id')->on('users')
|
||||
->onDelete('restrict')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('questionchoices');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateRespondentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('respondents', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
||||
$table->string('name', 100);
|
||||
|
||||
$table->string('handphone', 100);
|
||||
|
||||
$table->string('email', 100)
|
||||
->unique();
|
||||
|
||||
$table->enum('gender', ['m', 'f']);
|
||||
|
||||
$table->string('occupation', 100);
|
||||
|
||||
$table->date('birthdate');
|
||||
|
||||
$table->integer('category_id')
|
||||
->unsigned()
|
||||
->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->softDeletes();
|
||||
|
||||
|
||||
$table->foreign('category_id')
|
||||
->references('id')->on('categories')
|
||||
->onDeletes('restrict')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('respondents');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateAnswersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('answers', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
|
||||
$table->integer('respondent_id')
|
||||
->unsigned()
|
||||
->nullable();
|
||||
|
||||
$table->integer('question_id')
|
||||
->unsigned()
|
||||
->nullable();
|
||||
|
||||
$table->text('text');
|
||||
|
||||
$table->integer('questionchoice_id')
|
||||
->unsigned()
|
||||
->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->softDeletes();
|
||||
|
||||
|
||||
$table->foreign('respondent_id')
|
||||
->references('id')->on('respondents')
|
||||
->onDeletes('restrict')
|
||||
->onUpdate('cascade');
|
||||
|
||||
$table->foreign('question_id')
|
||||
->references('id')->on('questions')
|
||||
->onDeletes('restrict')
|
||||
->onUpdate('cascade');
|
||||
|
||||
$table->foreign('questionchoice_id')
|
||||
->references('id')->on('questionchoices')
|
||||
->onDeletes('restrict')
|
||||
->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('answers');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user