samedi 23 janvier 2016

Cannot insert values into database in laravel 5.1

I have this problem, when I return all values from the form input it all returns values that were filled in. However when I persist into the database under the store method in my controller it insert empty values. Can anyone help me on this? Thank you. Below are my codes.

public function store(EnrollmentRequest $request)
{   
    return $request->all();
    return redirect('/enrollment/create');
}

As you could see on top, it returns all inputs. However when I persist it on the database it returns only the id and timestamps;

public function store(EnrollmentRequest $request)
{   
    $enrollment = Enrollment::create([$request->all()]);
    return $enrollment;  return redirect('/enrollment/create');
}

Also here's my enrollment table:

    Schema::create('enrollments', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('student_id');
        $table->string('subject_description');
        $table->string('subject_code');
        $table->time('schedule');
        $table->string('room_no');
        $table->integer('no_of_units');
        $table->string('section');
        $table->timestamps();
    });

also my subjects table:

Schema::create('subjects', function (Blueprint $table) {
        $table->increments('id');
        $table->string('subject_code');
        $table->string('subject_description');
        $table->time('schedule');
        $table->string('room_no');
        $table->integer('no_of_units');
        $table->timestamps();
    });

Your help are well appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire