从视图中,我正在传递4个值1)名称2)user_filter_id 3)user_staff_id 4)ticket_id,但不仅传递了“ ticket_id”,其他3个值也无法正常显示错误
鉴于我正在传递此值
<ul class="chatonline style-none ">
@foreach ($ticket_details as $key=>$ticket_detailss)
<li>
<h3 style="text-align:center ">TICKET ID<small class="text-success "><br type="text" id="ticket_id" name="ticket_id" >{{$ticket_detailss->ticket_id }}</small></h3>
</li>
<li>
<h3 style="text-align:center ">SUBJECT<small class="text-success "><br>{{$ticket_detailss->subject }}</small></h3>
</li>
<li>
<h3 style="text-align:center ">NAME<small class="text-success "><br type="text" id="names" name="names" >{{$ticket_detailss->name }}</small></h3>
</li>
<li>
<h3 style="text-align:center ">ID<small class="text-success "><br type="text" id="user_filter_id" name="user_filter_id" >{{$ticket_detailss->user_filter_id }}</small></h3>
</li>
<li>
<h3 style="text-align:center ">STAFF ID<small class="text-success "><br type="text" id="user_staff_id" name="user_staff_id" >{{$ticket_detailss->user_staff_id }}</small></h3>
</li>
@endforeach
<li class="p-20"></li>
</ul>
我的控制器
public function manager_send_messageChat(Request $request)
{
$this->validate($request, [
'message' => 'required|string|max:255',
'ticket_id' => 'string|max:255',
'name' => 'string|max:255',
'user_filter_id' => 'string|max:255',
'user_staff_id' => 'string|max:255',
]);
$input['message'] = $request->message;
$input['manager_staff_id'] = Auth::user()->staff_id;
$input['manager_filter_id'] = Auth::user()->id;
$input['manager_name'] = Auth::user()->name;
$input['reply_by'] = 'staff';
$input['ticket_id'] = $request->ticket_id;
$input['user_filter_id'] = $request->user_filter_id;
$input['user_staff_id'] = $request->user_staff_id;
$input['name'] = $request->name;
User_Ticket_Chat::create($input);
DB::table('user_tickets')->where('ticket_id', $request->ticket_id)->update(['manager_staff_id' => Auth::user()->staff_id,'status' => 'PENDING']);
return redirect('/ticket')->with('success',' THIS TICKET ASSIGNED FOR YOU .');
}
我面临错误
"SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_filter_id' cannot be null (SQL: insert into `user_tickets_chats` (`message`, `manager_staff_id`, `manager_filter_id`, `manager_name`, `reply_by`, `ticket_id`, `user_filter_id`, `user_staff_id`, `name`, `updated_at`, `created_at`) values (f, GSL_00006, 1, SUBDOMAIN, staff, 1560777803, , , , 2019-06-19 03:02:06, 2019-06-19 03:02:06))
我的模特
class User_Ticket extends Model { protected $table = 'user_tickets'; protected $fillable = [ 'user_filter_id','user_staff_id','ticket_id','subject','message','category','status','manager_staff_id','admin_staff_id','admin_processing','note_for_admin','prioritie','services','name']; }
答案 0 :(得分:0)
转到您的User_Ticket_Chat
模型并填充user_filter_id
protected $fillable = [
'user_filter_id'
];
答案 1 :(得分:0)
首先,您没有在视图中指定任何“输入”。例如,<br type="text" id="user_staff_id" name="user_staff_id" >
应该为<input type="text" id="user_staff_id" name="user_staff_id" >
,并且所有输入同样。
如果您仍然遇到此问题,以下指南可能会为您提供帮助。
在具有“可填充”的模型中,您需要允许要为查询插入的所有字段。例如protected $fillable = [......, 'user_filter_id'];
。或者,您需要为数据库中的“ user_filter_id”字段设置一些默认值。您可以使用迁移来做到这一点。
请通过eloquent来了解有关可填充内容的更多信息。