IdentityVerification.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. class IdentityVerification extends Model
  7. {
  8. use HasFactory;
  9. protected $table = 'identity_verifications';
  10. protected $fillable = [
  11. 'user_id',
  12. 'session_id',
  13. 'session_token',
  14. 'workflow_id',
  15. 'didit_status',
  16. 'attempt',
  17. 'id_verification_status',
  18. 'liveness_status',
  19. 'face_match_status',
  20. 'liveness_score',
  21. 'face_match_score',
  22. 'warnings',
  23. 'decision',
  24. 'reviewed_by',
  25. 'reviewed_at',
  26. 'review_comment',
  27. 'started_at',
  28. 'completed_at',
  29. ];
  30. protected function casts(): array
  31. {
  32. return [
  33. 'attempt' => 'integer',
  34. 'liveness_score' => 'float',
  35. 'face_match_score' => 'float',
  36. 'warnings' => 'array',
  37. 'decision' => 'array',
  38. 'reviewed_at' => 'datetime',
  39. 'started_at' => 'datetime',
  40. 'completed_at' => 'datetime',
  41. ];
  42. }
  43. public function user(): BelongsTo
  44. {
  45. return $this->belongsTo(User::class);
  46. }
  47. public function reviewer(): BelongsTo
  48. {
  49. return $this->belongsTo(User::class, 'reviewed_by');
  50. }
  51. /** Warnings acionaveis: o Didit marca os informativos com log_type = information. */
  52. public function actionableWarnings(): array
  53. {
  54. return array_values(array_filter(
  55. $this->warnings ?? [],
  56. static fn ($warning) => data_get($warning, 'log_type') === 'warning',
  57. ));
  58. }
  59. }