AgentLoginLog.php 726 B

123456789101112131415161718192021
  1. <?php
  2. namespace App\Models\Agent;
  3. use App\Models\BaseModel;
  4. class AgentLoginLog extends BaseModel
  5. {
  6. protected $table = 'agent_login_logs';
  7. protected $fillable = ['agent_id', 'username', 'domain', 'ip', 'country', 'region', 'city', 'device', 'user_agent', 'login_at'];
  8. protected $hidden = [];
  9. protected $appends = ['device_text', 'location'];
  10. protected $casts = ['agent_id' => 'integer', 'login_at' => 'datetime'];
  11. public function getDeviceTextAttribute(): string
  12. {
  13. return $this->device === 'mobile' ? '手机端' : '电脑端';
  14. }
  15. public function getLocationAttribute(): string
  16. {
  17. return implode(' ', array_filter([$this->country, $this->region, $this->city]));
  18. }
  19. }