Monday, April 30, 2018

In laravel data is not inserting into database - development

In laravel data is not inserting into database

I am new to laravel and doing project using laravel framework please help me to solve this problem.

data is not inserting into table.

routes.php

Route::post('report/save','TestingController@store');

TestingController

 public function store(Request $request){
        $userId = Auth::user()->id;
        $this->validate($request, [
            'from_stk_loc' => 'required',
            'testing_date' => 'required',
            'casting_date' => 'required',
            'debtor_no' => 'required',
            'concrete_grade' => 'required',
            'testing_age' => 'required',
        ]);

        $test_details['client_id'] = $request->debtor_no;
        $test_details['location'] = $request->from_stk_loc;
        $test_details['casting_date'] = $request->casting_date;
        $test_details['testing_date'] = $request->testing_date;
        $test_details['concrete_grade'] = $request->concrete_grade;
        $test_details['testing_age'] = $request->testing_age;
        $test_details['report_date'] = date('Y-m-d');

        $test_detailsId = DB::table('testing_report')->insert($test_details);


    }

Model-> Testing.php

<?php

namespace AppModel;
use DB;
use IlluminateDatabaseEloquentModel;

class Testing extends Model
{
    protected $table = 'testing_report';
    protected $fillable = [
    'client_id',
    'location',
    'casting_date',
    'testing_date',
    'concrete_grade',
    'testing_age',
];
}



from Laravel Questions and Answers https://laravelquestions.com/laravel/in-laravel-data-is-not-inserting-into-database/
via Lzo Media

No comments:

Post a Comment