Example #1
0
 public static function createNotif($idUsu, $log)
 {
     if (is_array($idUsu)) {
         $data = array();
         foreach ($idUsu as $usr) {
             $data[] = ['usuario_id' => $usr, 'notificable_id' => $log->getKey(), 'notificable_type' => $log->getMorphClass()];
         }
         if (!empty($data)) {
             Notificacion::insert($data);
         }
     } else {
         $notif = new Notificacion();
         $notif->usuario_id = $idUsu;
         $notif->notificable()->associate($log);
         $notif->save();
     }
 }