belongsTo(User::class, 'user_id'); } public function xprofile() { return $this->belongsTo(XProfile::class, 'user_id', 'user_id'); } public function scopeForChannel($query, $channel) { return $query->where('channel', $channel); } public function scopeForEvent($query, $eventKey) { return $query->where('event_key', $eventKey); } /** * Global prefs (not scoped to a space or other object) use object_id = 0 * rather than NULL so the unique key can enforce one row per cell. */ public function scopeGlobalScoped($query) { return $query->where('object_id', 0); } public function scopeEnabled($query) { return $query->where('value', 1); } }