When i update my table with data there is a two extra fields found which i am not added on my table.Let me show my code with detail.
Migration table inquiry_plan detail:
public function up() { Schema::create('inquiry_plan', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('inquiry_id'); $table->string('title_vacation'); $table->string('email'); $table->string('phone_no', 20)->nullable(); $table->dateTime('start_date')->nullable(); $table->dateTime('end_date')->nullable(); $table->foreign('inquiry_id')->references('id')->on('inquiry_master'); }); } On my planController added a function for add activity:
Here is my controller function
public function addactivity(Request $request) { try { $validator = Validator::make($request->all(), Inquiryplan::planRules(), Inquiryplan::PlanMessages()); $plandetails = Inquiryplan::SaveOrUpdate($request); if($plandetails !== false) { return redirect()->route('plan')->with('success', trans('Plan details added successfully.!!')); } else { return back()->with('error', "Unable to save plan details.!!")->withInput(); } } catch (\Exception $ex) { dd($ex); return back()->with('error', "Unable to save plan details.!!")->withInput()->withErrors($validator); } } And finally saveOrupdate function in my model.
Here is my model function
public static function SaveOrUpdate(Request $request) { try { $id = $request->get('id', false); $plandetails = false; DB::transaction(function () use ($request, &$plandetails, $id) { $plandetails = $id ? Inquiryplan::findOrFail($id) : new Inquiryplan(); $plandetails->fill($request->all()); try { $plandetails->save(); } catch (\Exception $ex) { throw $ex; } dd($ex); }); return $plandetails; } catch (\Exception $ex) { throw $ex; } } When i submit my form it return error
"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list' (SQL: insert into
inquiry_plan(inquiry_id,title_vacation,phone_no,start_date,end_date,updated_at,created_at) values (0, test title, 9974031835, 2018-02-06, 2018-02-14, 2018-02-06 10:44:45, 2018-02-06 10:44:45))
what is the problem ?