1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-23 16:24:29 +00:00
pixelfed/app/UserDevice.php
2019-04-15 13:21:33 -06:00

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;
}
}