mardi 21 juillet 2020

base table or view not found?

when i enter question and click on add button i show error base table not found i cant understand what is issue and its solution so if any one know help me...i waste lot of time on it am begninner so difficult to identify error... web.php

Route::post('/admin/add_new_question','Admin@add_new_question');

AdminController

  public function add_new_question(Request $request)
    {
        $validator=Validator::make($request->all(),['question'=>'required','option1'=>'required','option2'=>'required','option3'=>'required','option4'=>'required','ans'=>'required']);
    if($validator->passes())
    {
        $question = new Oex_exam_question_master();
        $question->exam_id=$request->exam_id;
        $question->question=$request->question;
        $question->ans=$request->ans;
        $question->options=json_encode(array('option1'=>$request->option1,'option2'=>$request->option2,'option3'=>$request->option3,'option4'=>$request->option4));
        $question->save();
        $arr=array('status'=>'true','message'=>'Question Successfully Added','reload'=>url('admin/add_question/'.$request->exam_id));
    }
    else{
        $arr=array('status'=>'false','message'=>$validator->errors()->all());
    }
    echo json_encode($arr);
    }

add_question.blade.php

@extends('layouts.app')
@section('title','Exam Question')
@section('content')
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0 text-dark">Exam Question</h1>
                    </div><!-- /.col -->
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">Home</a></li>
                            <li class="breadcrumb-item active">Exam Question</li>
                        </ol>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.container-fluid -->
        </div>
        <!-- /.content-header -->
        <section class="content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-12">
                        <!-- Default box -->
                        <div class="card">
                            <div class="card-header">
                                <div class="card-tools">
                                    <a class="btn btn-info btn-sm" href="javascript:;" data-toggle="modal" data-target="#myModal">Add New</a>
                                </div>
                            </div>
                            <div class="card-body">
                                <table class="table table-striped table-bordered table-hover datatable">
                                    <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Question</th>
                                        <th>Ans</th>
                                        <th>Status</th>
                                        <th>Action</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <th>#</th>
                                        <th>Question</th>
                                        <th>Ans</th>
                                        <th>Status</th>
                                        <th>Action</th>
                                    </tr>
                                    </tfoot>
                                </table>
                            </div>
                            <!-- /.card-body -->

                            <!-- /.card-footer-->
                        </div>
                        <!-- /.card -->
                    </div>
                </div>
            </div>
        </section>
        <div class="modal fade" id="myModal" role="dialog">
            <div class="modal-dialog modal-lg">

                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Add New Exam</h4>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                    </div>
                    <div class="modal-body">
                        <form action=" " class="database_operation">
                            <div class="row">
                                <div class="col-sm-12">
                                    <div class="form-group">
                                        <label>Enter Question</label>
                                        
                                        <input type="hidden" name="exam_id" value="">
                                        <input type="text" name="question" required="required" placeholder="Enter Question" class="form-control">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Select Option 1</label>
                                        <input type="text" required="required" name="option1" placeholder="Enter Option 1"  class="form-control">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Select Option 2</label>
                                        <input type="text" required="required" name="option2" placeholder="Enter Option 2"  class="form-control">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Select Option 3</label>
                                        <input type="text" required="required" name="option3" placeholder="Enter Option 3"  class="form-control">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="form-group">
                                        <label>Select Option 4</label>
                                        <input type="text" required="required" name="option4" placeholder="Enter Option 4"  class="form-control">
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="form-group">
                                        <label>Enter Right Ans</label>
                                        <input type="text" required="required" name="ans" placeholder="Enter Right Ans"  class="form-control">
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="form-group">
                                        <button class="btn btn-primary"> Add</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>


    </div>
@endsection

Table oex_exam_question_master

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOexExamQuestionMastersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('oex_exam_question_masters', function (Blueprint $table) {
            $table->increments('id');
            $table->string('exam_id')->nullable();
            $table->string('question')->nullable();
            $table->string('ans')->nullable();
            $table->string('options')->nullable();
            $table->string('status')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('oex_exam_question_masters');
    }
}

Error

{
    "message": "SQLSTATE[42S02]: Base table or view not found: 1146 Table 'my_pro_online_ex.oex_exam_question_master' doesn't exist (SQL: insert into `oex_exam_question_master` (`exam_id`, `question`, `ans`, `options`, `updated_at`, `created_at`) values (4, Question 2, D, {\"option1\":\"A\",\"option2\":\"B\",\"option3\":\"C\",\"option4\":\"D\"}, 2020-07-21 07:32:03, 2020-07-21 07:32:03))",
    "exception": "Illuminate\\Database\\QueryException",
    "file": "C:\\xampp\\htdocs\\project\\online_exm_sys\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php",
    "line": 664,
    "trace": [
        {
            "file": "C:\\xampp\\htdocs\\project\\online_exm_sys\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connection.php",
            "line": 624,
            "function": "runQueryCallback",
            "class": "Illuminate\\Database\\Connection",
            "type": "->"


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire