我已经创建了一个laravel应用程序来存储员工数据,但当我提交表单时,它给了我以下错误,我应该做些什么来避免这个问题。谢谢
这是我的EmployeeController存储方法
public function store(Request $request)
{
$this->validate($request,array(
'lastname'=>'required|max:60',
'firstname'=>'required|max:60',
'middlename'=>'required|max:60',
'address'=>'required|max:120',
'NIC'=>'required|max:10',
'city_id'=>'required|max:60',
'state_id'=>'required|max:60',
'mobile'=>'required|max:10',
'email'=>'required|max:60',
'postal_code'=>'required|max:10',
'birthdate'=>'required|date',
'date_hired'=>'required|date',
'department_id'=>'required|max:10',
));
$employee = new Employee();
$employee->lastname=$request->lastname;
$employee->firstname=$request->firstname;
$employee->middlename=$request->middlename;
$employee->address=$request->address;
$employee->NIC=$request->NIC;
$employee->city_id=$request->city_id;
$employee->state_id=$request->state_id;
$employee->mobile=$request->mobile;
$employee->email->$request->email;
$employee->postal_code=$request->postal_code;
$employee->birthdate=$request->birthdate;
$employee->date_hired=$request->date_hired;
$employee->department_id=$request->department_id;
$employee->save();
}
表格页眉
{!! Form::open(['route'=>'employee.store','class'=>'form-horizontal p-t-20']) !!}
用于控制器的类
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Department;
use Illuminate\Support\Facades\DB;
use App\Employee;
4条答案
按热度按时间hs1rzwqc1#
您的代码中有错误。
这应该是,
wlzqhblo2#
看起来你正在尝试验证
$request
变量本身。因此Trying to get property POST
不应该是...0h4hbjxa3#
错误异常:尝试获取属性"POST/添加患者HTTP/1.1"
此错误是由于
当您在任何方法中定义变量时,请检查您没有按以下方式定义,因为它会给出错误$patients-〉address-〉$request-〉input('address ');
35g0bw714#
=未-〉在电子邮件中!($employee -〉email = $request -〉email);