NotificationApi.php 727 B

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