<?php

use App\Models\Permission;
use App\Models\Role;
use App\Models\User;
use Spatie\Permission\DefaultTeamResolver;

return [
    'models' => [
        'permission' => Permission::class,
        'role' => Role::class,
        'team' => null,
        'default_model' => User::class,
    ],

    'table_names' => [
        'roles' => 'roles',
        'permissions' => 'permissions',
        'model_has_permissions' => 'model_has_permissions',
        'model_has_roles' => 'model_has_roles',
        'role_has_permissions' => 'role_has_permissions',
    ],

    'column_names' => [
        'role_pivot_key' => null,
        'permission_pivot_key' => null,
        'model_morph_key' => 'model_id',
        'team_foreign_key' => 'team_id',
    ],

    /*
     * Phase 2 makes Spatie the runtime authorization source. Laravel's native
     * Gate/can()/@can APIs now resolve permissions from model_has_roles and
     * role_has_permissions. Legacy pivots remain mirrors only for parity checks.
     */
    'register_permission_check_method' => true,
    'register_octane_reset_listener' => false,
    'events_enabled' => false,

    /* Branch isolation remains intentionally independent from Spatie Teams. */
    'teams' => false,
    'team_resolver' => DefaultTeamResolver::class,

    'use_passport_client_credentials' => false,
    'display_permission_in_exception' => false,
    'display_role_in_exception' => false,
    'enable_wildcard_permission' => false,

    'cache' => [
        'expiration_time' => DateInterval::createFromDateString('24 hours'),
        'key' => 'spatie.permission.cache',
        'store' => 'default',
    ],
];
