<?php
namespace App\Traits;
trait HasPermissions {
    public function hasFeature(string $feature): bool {
        $tenant = $this instanceof \App\Models\Tenant ? $this : null;
        if (!$tenant) return false;
        if ($tenant->isTrialActive()) return true;
        if (!$tenant->isActive() || !$tenant->plan_id) return false;
        $plan     = \App\Models\SubscriptionPlan::find($tenant->plan_id);
        $features = json_decode($plan?->features_json ?? '{}', true);
        return !empty($features[$feature]);
    }
}
