belongsTo(User::class, 'user_id', 'ID'); } /** * Scope query to get meta by key */ public function scopeByKey($query, $key) { return $query->where('meta_key', $key); } /** * Scope query to get meta by user ID */ public function scopeByUser($query, $userId) { return $query->where('user_id', $userId); } }