Type hint model relations (#12673)

This commit is contained in:
Jellyfrog
2021-03-30 11:14:34 +02:00
committed by GitHub
parent 422d1195c6
commit 64e50e4d85
11 changed files with 104 additions and 84 deletions
+4 -2
View File
@@ -25,6 +25,8 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use LibreNMS\Enum\AlertState;
class AlertRule extends BaseModel
@@ -78,12 +80,12 @@ class AlertRule extends BaseModel
// ---- Define Relationships ----
public function alerts()
public function alerts(): HasMany
{
return $this->hasMany(\App\Models\Alert::class, 'rule_id');
}
public function devices()
public function devices(): BelongsToMany
{
return $this->belongsToMany(\App\Models\Device::class, 'alert_device_map', 'device_id', 'device_id');
}