数据未提交到DB Laravel:5.8中



嗨,我试图将数据保存在数据库中,但它没有保存 蚂蚁说 404|不是发现

控制器:

   DB::table('forms')->insert([
        'patient_insurance' => $request->patient_insurance,
        'patient_insurance_id' => $request->patient_insurance_id,
        'patient_reason' => $request->patient_reason,
        'patient_new' => $request->patient_new,
        'patient_message' => $request->patient_message,
    ]);
    return back();

路线:

  Route::resource('form', 'FormController');

叶片:

  <form method="post" action="{{ route('form.store')}}">

型:

   protected $guarded = [];
   protected $table = "forms";
   protected $fillable= 
   ['patient_name','patient_insurance','patient_insurance_id', 
   'patient_reason', 'patient_new', 'patient_message'];

任何人都可以告诉我这个问题

你不是应该在 FormController 类的存储函数中插入你的数据吗?

<?php
namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppHttpRequests;
use AppHttpControllersController;
use AppPatient;
class FormController extends Controller{
    public function store(Request $request){
        $patient = new Patient;
        $patient->patient_insurance = $request->input('patient_insurance');
        $patient->patient_insurance_id = $request->input('patient_insurance_id');
        $patient->patient_reason = $request->input('patient_reason');
        $patient->patient_new = $request->$request->input('patient_new);
        $patient->patient_message = $request->input('patient_message');
        $patient->save();
        return back();
    }
}

最新更新