'Laravel : Bulk Insert Other and Ignore Error Exception Duplication

In mysql I have set unique key on column url and in Laravel controller I have create key value pairs of array to prepare bulk insert. I want to insert by ignore error duplication exception but insert for anothers. I have the following code:

controller.php

try{
    $container = array();
    foreach ($js->RECORDS as $rec) {
        $data = [
         'title'=>$rec->title,
         'description'=>$rec->description,
         'url'=>$rec->url
        ];
       array_push($container, $data);
    }
    $status = Model::insert($container);
 }catch (\Exception $e){
   $req->session()->flash('alert-danger', $e->getMessage()); 
 }


Solution 1:[1]

try{
    foreach ($js->RECORDS as $rec) {
        $data = [
         'title'=>$rec->title,
         'description'=>$rec->description,
         'url'=>$rec->url
        ];
    $status = Model::updateOrCreate(['url' => $rec->url], $data);
   }
}catch (\Exception $e){
   $req->session()->flash('alert-danger', $e->getMessage()); 
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rem