NotificationApi.php 735 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Http\Api;
  3. use App\Models\Notification;
  4. use Illuminate\Support\Str;
  5. class NotificationApi
  6. {
  7. public static function send($data)
  8. {
  9. $insertData = [];
  10. foreach ($data as $key => $row) {
  11. $insertData[] = [
  12. 'id' => Str::uuid(),
  13. 'from' => $row['from'],
  14. 'to' => $row['to'],
  15. 'url' => $row['url'],
  16. 'content' => $row['content'],
  17. 'res_type' => $row['res_type'],
  18. 'res_id' => $row['res_id'],
  19. 'updated_at' => now(),
  20. 'created_at' => now(),
  21. ];
  22. }
  23. $insert = Notification::insert($insertData);
  24. return $insert;
  25. }
  26. }