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');
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// $this->call(UsersTableSeeder::class);
|
||||
$this->call(UsersTableSeeder::class);
|
||||
$this->call(QuestionnairesSeeder::class);
|
||||
$this->call(RespondentSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
2128
database/seeds/QuestionnairesSeeder.php
Normal file
2128
database/seeds/QuestionnairesSeeder.php
Normal file
File diff suppressed because it is too large
Load Diff
25
database/seeds/RespondentSeeder.php
Normal file
25
database/seeds/RespondentSeeder.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Respondent;
|
||||
|
||||
class RespondentSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
Respondent::create([
|
||||
'name' => 'respondent1',
|
||||
'handphone' => '0123456789',
|
||||
'email' => 'respondent1@company.com',
|
||||
'gender' => 'm',
|
||||
'occupation' => 'staff',
|
||||
'birthdate' => '2017/01/01',
|
||||
'category_id' => '1'
|
||||
]);
|
||||
}
|
||||
}
|
||||
22
database/seeds/UsersTableSeeder.php
Normal file
22
database/seeds/UsersTableSeeder.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\User;
|
||||
|
||||
class UsersTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
User::create([
|
||||
'username' => 'user1',
|
||||
'name' => 'User 1',
|
||||
'email' => 'user1@company.com',
|
||||
'password' => 'user1'
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user