mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Type hint all device model relations (#12686)
This commit is contained in:
@@ -30,6 +30,7 @@ use Date;
|
||||
use DB;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Enum\AlertScheduleStatus;
|
||||
|
||||
@@ -202,17 +203,17 @@ class AlertSchedule extends Model
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function devices()
|
||||
public function devices(): MorphToMany
|
||||
{
|
||||
return $this->morphedByMany(\App\Models\Device::class, 'alert_schedulable', 'alert_schedulables', 'schedule_id', 'alert_schedulable_id');
|
||||
}
|
||||
|
||||
public function deviceGroups()
|
||||
public function deviceGroups(): MorphToMany
|
||||
{
|
||||
return $this->morphedByMany(\App\Models\DeviceGroup::class, 'alert_schedulable', 'alert_schedulables', 'schedule_id', 'alert_schedulable_id');
|
||||
}
|
||||
|
||||
public function locations()
|
||||
public function locations(): MorphToMany
|
||||
{
|
||||
return $this->morphedByMany(\App\Models\Location::class, 'alert_schedulable', 'alert_schedulables', 'schedule_id', 'alert_schedulable_id');
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
|
||||
class AlertTemplate extends BaseModel
|
||||
{
|
||||
public $timestamps = false;
|
||||
@@ -35,7 +37,7 @@ class AlertTemplate extends BaseModel
|
||||
return $this->hasMany(\App\Models\AlertTemplateMap::class, 'alert_templates_id', 'id');
|
||||
}
|
||||
|
||||
public function alert_rules()
|
||||
public function alert_rules(): HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(\App\Models\AlertRule::class, \App\Models\AlertTemplateMap::class, 'alert_templates_id', 'id', 'id', 'alert_rule_id')
|
||||
->select(['id' => 'alert_rules.id', 'name' => 'alert_rules.name'])
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class AlertTemplateMap extends BaseModel
|
||||
{
|
||||
protected $table = 'alert_template_map';
|
||||
@@ -31,7 +33,7 @@ class AlertTemplateMap extends BaseModel
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function template()
|
||||
public function template(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\AlertTemplate::class, 'alert_templates_id');
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ApiToken extends BaseModel
|
||||
{
|
||||
public $timestamps = false;
|
||||
@@ -91,7 +93,7 @@ class ApiToken extends BaseModel
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function user()
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'user_id');
|
||||
}
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Bill extends Model
|
||||
{
|
||||
@@ -48,7 +49,7 @@ class Bill extends Model
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function ports()
|
||||
public function ports(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(\App\Models\Port::class, 'bill_ports', 'bill_id', 'bill_id');
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Component extends DeviceRelatedModel
|
||||
{
|
||||
@@ -53,12 +54,12 @@ class Component extends DeviceRelatedModel
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function logs()
|
||||
public function logs(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\ComponentStatusLog::class, 'component_id', 'id');
|
||||
}
|
||||
|
||||
public function prefs()
|
||||
public function prefs(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\ComponentPref::class, 'component', 'id');
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Dashboard extends Model
|
||||
{
|
||||
@@ -46,12 +48,12 @@ class Dashboard extends Model
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function user()
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function widgets()
|
||||
public function widgets(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\UserWidget::class, 'dashboard_id');
|
||||
}
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
// class DeviceOutage extends Model
|
||||
class DeviceOutage extends DeviceRelatedModel
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use LibreNMS\Enum\Alert;
|
||||
|
||||
class Eventlog extends DeviceRelatedModel
|
||||
@@ -65,7 +66,7 @@ class Eventlog extends DeviceRelatedModel
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function related()
|
||||
public function related(): MorphTo
|
||||
{
|
||||
return $this->morphTo('related', 'type', 'reference');
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Ipv4Mac extends PortRelatedModel
|
||||
{
|
||||
protected $table = 'ipv4_mac';
|
||||
@@ -9,7 +11,7 @@ class Ipv4Mac extends PortRelatedModel
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function device()
|
||||
public function device(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Device::class, 'device_id');
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Ipv4Network extends Model
|
||||
{
|
||||
@@ -36,7 +37,7 @@ class Ipv4Network extends Model
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function ipv4()
|
||||
public function ipv4(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\Ipv4Address::class, 'ipv4_network_id');
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Ipv6Network extends Model
|
||||
{
|
||||
@@ -33,7 +34,7 @@ class Ipv6Network extends Model
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function ipv6()
|
||||
public function ipv6(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\Ipv6Address::class, 'ipv6_network_id');
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use LibreNMS\Interfaces\Models\Keyable;
|
||||
|
||||
class MplsLsp extends Model implements Keyable
|
||||
@@ -46,7 +47,7 @@ class MplsLsp extends Model implements Keyable
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function paths()
|
||||
public function paths(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\MplsLspPath::class, 'lsp_id');
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use LibreNMS\Interfaces\Models\Keyable;
|
||||
|
||||
class MplsLspPath extends Model implements Keyable
|
||||
@@ -45,7 +46,7 @@ class MplsLspPath extends Model implements Keyable
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function lsp()
|
||||
public function lsp(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\MplsLsp::class, 'lsp_id');
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use LibreNMS\Interfaces\Models\Keyable;
|
||||
|
||||
class MplsSap extends Model implements Keyable
|
||||
@@ -38,12 +39,12 @@ class MplsSap extends Model implements Keyable
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function binds()
|
||||
public function binds(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\MplsSdpBind::class, 'svc_id');
|
||||
}
|
||||
|
||||
public function services()
|
||||
public function services(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\MplsService::class, 'svc_id');
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use LibreNMS\Interfaces\Models\Keyable;
|
||||
|
||||
class MplsSdp extends Model implements Keyable
|
||||
@@ -39,7 +40,7 @@ class MplsSdp extends Model implements Keyable
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function binds()
|
||||
public function binds(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\MplsSdpBind::class, 'sdp_id');
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use LibreNMS\Interfaces\Models\Keyable;
|
||||
|
||||
class MplsSdpBind extends Model implements Keyable
|
||||
@@ -41,12 +42,12 @@ class MplsSdpBind extends Model implements Keyable
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function sdp()
|
||||
public function sdp(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\MplsSdp::class, 'sdp_id');
|
||||
}
|
||||
|
||||
public function service()
|
||||
public function service(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\MplsService::class, 'svc_id');
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use LibreNMS\Interfaces\Models\Keyable;
|
||||
|
||||
class MplsService extends Model implements Keyable
|
||||
@@ -45,7 +46,7 @@ class MplsService extends Model implements Keyable
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function binds()
|
||||
public function binds(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\MplsSdpBind::class, 'svc_id');
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Notification extends Model
|
||||
@@ -133,10 +134,7 @@ class Notification extends Model
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function attribs()
|
||||
public function attribs(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\NotificationAttrib::class, 'notifications_id', 'notifications_id');
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class NotificationAttrib extends Model
|
||||
{
|
||||
@@ -13,18 +14,12 @@ class NotificationAttrib extends Model
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function user()
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function notification()
|
||||
public function notification(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Notification::class, 'notifications_id');
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class OspfPort extends PortRelatedModel
|
||||
{
|
||||
@@ -65,7 +66,7 @@ class OspfPort extends PortRelatedModel
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function device()
|
||||
public function device(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Device::class, 'device_id');
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use LibreNMS\Exceptions\InvalidNameException;
|
||||
|
||||
class PollerCluster extends Model
|
||||
@@ -260,7 +261,7 @@ class PollerCluster extends Model
|
||||
|
||||
// ---- Relationships ----
|
||||
|
||||
public function stats()
|
||||
public function stats(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\PollerClusterStat::class, 'parent_poller', 'id');
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class PollerGroup extends Model
|
||||
{
|
||||
@@ -51,7 +52,7 @@ class PollerGroup extends Model
|
||||
return self::query()->pluck('group_name', 'id')->prepend(__('General'), 0);
|
||||
}
|
||||
|
||||
public function devices()
|
||||
public function devices(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\Device::class, 'poller_group', 'id');
|
||||
}
|
||||
|
||||
+18
-15
@@ -5,6 +5,9 @@ namespace App\Models;
|
||||
use DB;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Util\Rewrite;
|
||||
use Permissions;
|
||||
@@ -254,78 +257,78 @@ class Port extends DeviceRelatedModel
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function adsl()
|
||||
public function adsl(): HasMany
|
||||
{
|
||||
return $this->hasMany(PortAdsl::class, 'port_id');
|
||||
}
|
||||
|
||||
public function events()
|
||||
public function events(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Eventlog::class, 'events', 'type', 'reference');
|
||||
}
|
||||
|
||||
public function fdbEntries()
|
||||
public function fdbEntries(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\PortsFdb::class, 'port_id', 'port_id');
|
||||
}
|
||||
|
||||
public function ipv4()
|
||||
public function ipv4(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\Ipv4Address::class, 'port_id');
|
||||
}
|
||||
|
||||
public function ipv6()
|
||||
public function ipv6(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\Ipv6Address::class, 'port_id');
|
||||
}
|
||||
|
||||
public function macAccounting()
|
||||
public function macAccounting(): HasMany
|
||||
{
|
||||
return $this->hasMany(MacAccounting::class, 'port_id');
|
||||
}
|
||||
|
||||
public function macs()
|
||||
public function macs(): HasMany
|
||||
{
|
||||
return $this->hasMany(Ipv4Mac::class, 'port_id');
|
||||
}
|
||||
|
||||
public function nac()
|
||||
public function nac(): HasMany
|
||||
{
|
||||
return $this->hasMany(PortsNac::class, 'port_id');
|
||||
}
|
||||
|
||||
public function ospfNeighbors()
|
||||
public function ospfNeighbors(): HasMany
|
||||
{
|
||||
return $this->hasMany(OspfNbr::class, 'port_id');
|
||||
}
|
||||
|
||||
public function ospfPorts()
|
||||
public function ospfPorts(): HasMany
|
||||
{
|
||||
return $this->hasMany(OspfPort::class, 'port_id');
|
||||
}
|
||||
|
||||
public function pseudowires()
|
||||
public function pseudowires(): HasMany
|
||||
{
|
||||
return $this->hasMany(Pseudowire::class, 'port_id');
|
||||
}
|
||||
|
||||
public function statistics()
|
||||
public function statistics(): HasMany
|
||||
{
|
||||
return $this->hasMany(PortStatistic::class, 'port_id');
|
||||
}
|
||||
|
||||
public function stp()
|
||||
public function stp(): HasMany
|
||||
{
|
||||
return $this->hasMany(PortStp::class, 'port_id');
|
||||
}
|
||||
|
||||
public function users()
|
||||
public function users(): BelongsToMany
|
||||
{
|
||||
// FIXME does not include global read
|
||||
return $this->belongsToMany(\App\Models\User::class, 'ports_perms', 'port_id', 'user_id');
|
||||
}
|
||||
|
||||
public function vlans()
|
||||
public function vlans(): HasMany
|
||||
{
|
||||
return $this->hasMany(PortVlan::class, 'port_id');
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class PortsNac extends PortRelatedModel
|
||||
{
|
||||
protected $table = 'ports_nac';
|
||||
@@ -50,7 +52,7 @@ class PortsNac extends PortRelatedModel
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function device()
|
||||
public function device(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Device::class, 'device_id', 'device_id');
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Route extends DeviceRelatedModel
|
||||
{
|
||||
protected $table = 'route';
|
||||
@@ -39,7 +41,7 @@ class Route extends DeviceRelatedModel
|
||||
public $timestamps = true;
|
||||
|
||||
// ---- Define Relationships ----
|
||||
public function port()
|
||||
public function port(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Port::class, 'port_id', 'port_id');
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
class Sensor extends DeviceRelatedModel
|
||||
{
|
||||
@@ -73,7 +74,7 @@ class Sensor extends DeviceRelatedModel
|
||||
}
|
||||
|
||||
// ---- Define Relationships ----
|
||||
public function events()
|
||||
public function events(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Eventlog::class, 'events', 'type', 'reference');
|
||||
}
|
||||
|
||||
+8
-5
@@ -5,6 +5,9 @@ namespace App\Models;
|
||||
use App\Events\UserCreated;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
@@ -183,7 +186,7 @@ class User extends Authenticatable
|
||||
|
||||
// ---- Define Relationships ----
|
||||
|
||||
public function apiToken()
|
||||
public function apiToken(): HasOne
|
||||
{
|
||||
return $this->hasOne(\App\Models\ApiToken::class, 'user_id', 'user_id');
|
||||
}
|
||||
@@ -196,7 +199,7 @@ class User extends Authenticatable
|
||||
});
|
||||
}
|
||||
|
||||
public function deviceGroups()
|
||||
public function deviceGroups(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(\App\Models\DeviceGroup::class, 'devices_group_perms', 'user_id', 'device_group_id');
|
||||
}
|
||||
@@ -211,17 +214,17 @@ class User extends Authenticatable
|
||||
}
|
||||
}
|
||||
|
||||
public function dashboards()
|
||||
public function dashboards(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\Dashboard::class, 'user_id');
|
||||
}
|
||||
|
||||
public function preferences()
|
||||
public function preferences(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\UserPref::class, 'user_id');
|
||||
}
|
||||
|
||||
public function widgets()
|
||||
public function widgets(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\UserWidget::class, 'user_id');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user