Skip to content

Instantly share code, notes, and snippets.

2 question_idIndex int(10) UNSIGNED Yes NULL Change Change Drop Drop
Primary Primary
Unique Unique
Index Index
More
3 option varchar(255) utf8_unicode_ci Yes NULL Change Change Drop Drop
Primary Primary
Unique Unique
Index Index
More
public function store(Request $request)
{
$ques = new Question();
$ques->question_text = $request['question_text'];
$ques->code_snippet = $request['code_snippet'];
$ques->answer_explanation = $request['answer_explanation'];
$ques->more_info_link = $request['more_info_link'];
$ques->category_id = $request['category_id'];
$ques->topic_id = $request['topic_id'];
dd($ques->save());
ouput of request
"_token" => "AEVBOOFQToeqh0yhCiTdJR7peCerZeWpUAIKWwzj"
"category_id" => "1"
"topic_id" => "1"
"question_text" => "question"
"option1" => "ans1"
"option2" => "ans2"
"option3" => "ans3"
"option4" => "ans4"
public function up()
{
Schema::create('topics', function (Blueprint $table) {
$table->increments('id');
$table->string('title')->nullable();
$table->string('duration')->nullable();
$table->timestamps();
$table->softDeletes();
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTopicsTable extends Migration
{
/**
* Run the migrations.
*
[Illuminate\Database\QueryException]
SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or upda
te a parent row: a foreign key constraint fails (SQL: drop table if exists
`topics`)
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateQuestionsTable extends Migration
{
/**
* Run the migrations.
*
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
Active: active (running) since Wed 2017-11-08 14:59:47 UTC; 4min 54s ago
Process: 20729 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=e
Process: 20717 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exi
Main PID: 20728 (mysqld)
Tasks: 28
Memory: 151.3M
CPU: 499ms
CGroup: /system.slice/mysql.service
APP_ENV=local
APP_KEY=base64:keyhere
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=www.onlineexamwala.com
DB_CONNECTION=mysql
DB_HOST=139.59.15.181
DB_PORT=3306
DB_DATABASE=questionbank
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_s
chema.tables where table_schema = questionbank and table_name = migrations)
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [2002] Connection refused