Laravel特定列的唯一关键字

I'm using "unique" keyword for validating unique users for employee_id in controllers, in my database there is column called company_id , while adding new user they will be set us some company_id ,when i add new user for my company employee id will be unique for my company itself , if employee_id is 4 for another company and i'm adding 4 for my company it must accept , it will check only for that particular company only.

       $this->validate($request, 
       [
        'name'      => 'required',
        'emp_id' => 'required|unique:users', (Here how can i check for particular company)
        'email' => 'required|unique:users',
        'role'  => 'required',
       ]); 

can anyone please help me ???

You should use the array syntax here and use a "custom" unique rule:

'emp_id' => [ "required",  Rule::unique('users')->where(function ($query) use ($request) {
   $query->where('emp_id', $request->emp_id)->where("company_id",$request->company_id); 
}) ]

Something like this anyway

If emp_id and company_id is in request

'emp_id' => 'required|unique:users,emp_id|unique:users,company_id',

Check in docs : https://laravel.com/docs/master/validation#rule-unique

I assume emp_id and company_id are present in users table and you are sending in request