Malzatic
Malzatic

Reputation: 41

error when trying to submit form to database

Hi so when I'm trying to submit my form to my database I get the following error

ERROR

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'urenregistratie.issues' doesn't exist (SQL: insert into `issues` (`iname`, `begroting`, `description`, `updated_at`, `created_at`) values (test, 100, test description, 2019-12-04 09:19:54, 2019-12-04 09:19:54))

CONTROLLER

public function store(Request $request)
    {
        $this->validate($request,[
            'iname' => 'required',
            'begroting' => 'required',
            'description' => 'required',

            ]);

            $issue = new Issue;

            $issue->iname = $request->input('iname');
            $issue->begroting = $request->input('begroting');
            $issue->description = $request->input('description');

            $issue->save();

            return redirect('/issue')->with('success', 'Data Saved');



    }

MIGRATION

   public function up()
    {
        Schema::create('issue', function (Blueprint $table) {
            $table->increments('id');
            $table->string('iname');
            $table->time('begroting');
            $table->mediumText('description');
            $table->timestamps();
        });
    }

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

Urenregistratie is my database name. but I don't know where its getting the issues from since I called it issue without the S so where is it getting the issues from

if I'm missing anything code wise if I do let me know.

Upvotes: 1

Views: 144

Answers (1)

Grace Brown
Grace Brown

Reputation: 81

Your migration creates issue table but you're saving to issues table. Check your table name in the model class.

class Issue extends Model
{
protected $table = 'issue'; // this table name
.
.
.
}

Upvotes: 2

Related Questions