mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-18 04:21:27 +00:00
34 lines
555 B
PHP
34 lines
555 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Jenssegers\Agent\Agent;
|
|
|
|
class UserDevice extends Model
|
|
{
|
|
protected $fillable = [
|
|
'user_id',
|
|
'ip',
|
|
'user_agent'
|
|
];
|
|
|
|
public $timestamps = [
|
|
'last_active_at'
|
|
];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function getUserAgent()
|
|
{
|
|
if(!$this->user_agent) {
|
|
return 'Unknown';
|
|
}
|
|
$agent = new Agent();
|
|
$agent->setUserAgent($this->user_agent);
|
|
return $agent;
|
|
}
|
|
}
|