DetectLog.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Models;
  3. /**
  4. * DetectLog Model
  5. */
  6. use App\Utils\Tools;
  7. class DetectLog extends Model
  8. {
  9. protected $connection = "default";
  10. protected $table = "detect_log";
  11. public function DetectRule()
  12. {
  13. $rule = DetectRule::where("id", $this->attributes['list_id'])->first();
  14. if ($rule == null) {
  15. DetectLog::where('id', '=', $this->attributes['id'])->delete();
  16. return null;
  17. } else {
  18. return $rule;
  19. }
  20. }
  21. public function User()
  22. {
  23. $user = User::where("id", $this->attributes['user_id'])->first();
  24. if ($user == null) {
  25. DetectLog::where('id', '=', $this->attributes['id'])->delete();
  26. return null;
  27. } else {
  28. return $user;
  29. }
  30. }
  31. public function Node()
  32. {
  33. $node = Node::where("id", $this->attributes['node_id'])->first();
  34. if ($node == null) {
  35. DetectLog::where('id', '=', $this->attributes['id'])->delete();
  36. return null;
  37. } else {
  38. return $node;
  39. }
  40. }
  41. }