I am using Laravel 5.5,I want to exclude duplicate records when inserting a group of data into mysql.
For example,there is a table students,it has these fields:
id
name
gender
Now I will insert a group of data into students,if not mind duplicate records,I can do it like this:
public function insert()
{
    $newStudents=[
        ['name'=>'Jim','gender'=>'boy'],
        ['name'=>'Lucy','gender'=>'girl'],
        ['name'=>'Jack','gender'=>'boy'],
        ['name'=>'Alice','gender'=>'girl']
    ];
    DB::table('students')->insert($newStudents);
}
Now I don't want to insert duplicate records.(The duplicate is : both name and gender have the same values,not one field has the same value).
what should I do?
 
     
    