mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
555 B
PHP
35 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;
|
|
}
|
|
}
|