数据未提交到数据库 laravel:5.8
data is not submitting into db laravel:5.8
您好,我正在尝试将数据保存在数据库中,但它没有保存,蚂蚁说 404|not
找到
控制器:
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');
blade:
<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 的存储函数中插入你的数据吗class?
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Patient;
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();
}
}
您好,我正在尝试将数据保存在数据库中,但它没有保存,蚂蚁说 404|not 找到
控制器:
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');
blade:
<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 的存储函数中插入你的数据吗class?
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Patient;
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();
}
}