问题
from view i am passing 4 values 1)name 2)user_filter_id 3)user_staff_id 4)ticket_id but it not only passing "ticket_id" other 3 values not working it showing error
In View I am Passing This Value
<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>
My controller
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 .');
}
I am facing error this
"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))
my model
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']; }
回答1:
Go to your User_Ticket_Chat
model and make user_filter_id
fillable
protected $fillable = [
'user_filter_id'
];
回答2:
First of all you have not specified any 'input' in your view. For example <br type="text" id="user_staff_id" name="user_staff_id" >
should be <input type="text" id="user_staff_id" name="user_staff_id" >
and likewise all inputs.
The following guidance may help you if you still facing this issue.
You need to allow all the fields you want to insert for a query in model with 'fillable'. for example protected $fillable = [......, 'user_filter_id'];
. Or you need to set some default value for "user_filter_id" field in db. You may use migration for doing that.
Please go through eloquent, to know more about fillable.
来源:https://stackoverflow.com/questions/56659578/in-laravel-my-controller-3-filed-value-not-passing