在laravel中我的控制器3提交的值未通过 [英] in laravel my controller 3 filed value not passing

查看:58
本文介绍了在laravel中我的控制器3提交的值未通过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从视图中我传递了4个值1)名称2)user_filter_id 3)user_staff_id 4)ticket_id,但它不仅传递了"ticket_id",其他3个值均不起作用,显示错误

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))

我的模特

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'];
}

推荐答案

首先,您没有在视图中指定任何输入".例如,<br type="text" id="user_staff_id" name="user_staff_id" >应该为<input type="text" id="user_staff_id" name="user_staff_id" >,同样所有输入也应如此.

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.

在具有可填充"的模型中,您需要允许您要为查询插入的所有字段.例如protected $fillable = [......, 'user_filter_id'];.或者,您需要为数据库中的"user_filter_id"字段设置一些默认值.您可以使用迁移来做到这一点.

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.

这篇关于在laravel中我的控制器3提交的值未通过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆