diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 7a842ea..1374a3d 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -6,6 +6,7 @@ use App\Models\App; use App\Models\Role; use App\Models\UserAppOverride; +use App\Models\Setting; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\Hash; @@ -19,8 +20,8 @@ class DatabaseSeeder extends Seeder */ public function run(): void { - // 1. Seed default administrator - $admin = User::updateOrCreate( + // 1. Seed default administrator (Preserve if already exists) + $admin = User::firstOrCreate( ['email' => 'admin@company.com'], [ 'name' => 'System Administrator', @@ -29,30 +30,105 @@ public function run(): void ] ); - // 2. Seed default apps - $outlook = App::updateOrCreate( - ['name' => 'Outlook'], + // 2. Seed default roles (Preserve description if modified) + $pmRole = Role::firstOrCreate( + ['name' => 'Project Manager'], + ['description' => 'Oversees projects, budgets, and milestones.'] + ); + + $leadRole = Role::firstOrCreate( + ['name' => 'Team Lead'], + ['description' => 'Manages dev teams and assigns work items.'] + ); + + $salesRole = Role::firstOrCreate( + ['name' => 'Sales Team'], + ['description' => 'Drives client acquisition and manages CRM leads.'] + ); + + $devRole = Role::firstOrCreate( + ['name' => 'Developer'], + ['description' => 'Writes code and builds features.'] + ); + + $internRole = Role::firstOrCreate( + ['name' => 'Intern'], + ['description' => 'Learning and assisting on project modules.'] + ); + + $hrRole = Role::firstOrCreate( + ['name' => 'HR Manager'], + ['description' => 'Handles recruitment, payroll, and employee relations.'] + ); + + // 3. Seed default apps/services (Preserve if already exists) + $outlookCalendar = App::firstOrCreate( + ['name' => 'Outlook Calendar'], [ - 'url' => 'https://outlook.office.com/mail/', + 'url' => 'https://outlook.cloud.microsoft/calendar/view/workweek?deeplink=mail%2F', 'icon_svg' => 'outlook', 'color' => '#0078d4', - 'desc' => 'Access your corporate mail, calendar, and contacts instantly.', + 'desc' => 'Access your workweek calendar and scheduled meetings.', 'tag' => 'Microsoft 365' ] ); - $teams = App::updateOrCreate( - ['name' => 'Microsoft Teams'], + $convexCrm = App::firstOrCreate( + ['name' => 'Convex CRM'], [ - 'url' => 'https://teams.microsoft.com/v2/', - 'icon_svg' => 'teams', - 'color' => '#6264a7', - 'desc' => 'Chat, meet, call, and collaborate with your team.', - 'tag' => 'Microsoft 365' + 'url' => 'https://convexsol.convexcrm.com/', + 'icon_svg' => 'keka', + 'color' => '#4f46e5', + 'desc' => 'Customer Relationship Management and lead tracking portal.', + 'tag' => 'CRM' ] ); - $keka = App::updateOrCreate( + $copilot = App::firstOrCreate( + ['name' => 'Microsoft Copilot'], + [ + 'url' => 'https://outlook.cloud.microsoft/host/b5abf2ae-c16b-4310-8f8a-d3bcdb52f162/entity1-d870f6cd-4aa5-4d42-9626-ab690c041429', + 'icon_svg' => 'teams', + 'color' => '#0078d4', + 'desc' => 'AI-powered productivity and search assistant.', + 'tag' => 'AI Assistant' + ] + ); + + $demoCrm = App::firstOrCreate( + ['name' => 'Convex Demo CRM'], + [ + 'url' => 'https://demo-convexcrm.convexsol.co/', + 'icon_svg' => 'keka', + 'color' => '#06b6d4', + 'desc' => 'Demonstration environment for Convex CRM features.', + 'tag' => 'CRM' + ] + ); + + $git = App::firstOrCreate( + ['name' => 'SentientGeeks Git'], + [ + 'url' => 'https://git.sentientgeeks.us/', + 'icon_svg' => 'outlook', + 'color' => '#f1502f', + 'desc' => 'Self-hosted repository hosting and code collaboration tool.', + 'tag' => 'Dev Tools' + ] + ); + + $internalCrm = App::firstOrCreate( + ['name' => 'Internal CRM'], + [ + 'url' => 'https://internal.convexcrm.com/', + 'icon_svg' => 'keka', + 'color' => '#10b981', + 'desc' => 'Internal client relations and account directory panel.', + 'tag' => 'CRM' + ] + ); + + $keka = App::firstOrCreate( ['name' => 'Keka HR'], [ 'url' => 'https://sentientgeeks.keka.com/', @@ -63,59 +139,77 @@ public function run(): void ] ); - // 3. Seed default roles - $pmRole = Role::updateOrCreate( - ['name' => 'Project Manager'], - ['description' => 'Oversees projects, budgets, and milestones.'] + $teams = App::firstOrCreate( + ['name' => 'Microsoft Teams'], + [ + 'url' => 'https://teams.microsoft.com/v2/', + 'icon_svg' => 'teams', + 'color' => '#6264a7', + 'desc' => 'Chat, meet, call, and collaborate with your team.', + 'tag' => 'Microsoft 365' + ] ); - $leadRole = Role::updateOrCreate( - ['name' => 'Team Lead'], - ['description' => 'Manages dev teams and assigns work items.'] + $outlookMail = App::firstOrCreate( + ['name' => 'Outlook Mail'], + [ + 'url' => 'https://outlook.cloud.microsoft/host/377c982d-9686-450e-9a7c-22aeaf1bc162/7211f19f-262a-42eb-a02e-289956491741', + 'icon_svg' => 'outlook', + 'color' => '#0078d4', + 'desc' => 'Corporate email and messaging inbox.', + 'tag' => 'Microsoft 365' + ] ); - $salesRole = Role::updateOrCreate( - ['name' => 'Sales Team'], - ['description' => 'Drives client acquisition and manages CRM leads.'] + $outlookMailSecondary = App::firstOrCreate( + ['name' => 'Outlook Mail (Secondary)'], + [ + 'url' => 'https://outlook.cloud.microsoft/host/1f8c20f5-d70f-4f8e-93e1-31d8fce0c8c9/096f3341-6ebc-45ac-b97f-e28aecd40b66', + 'icon_svg' => 'outlook', + 'color' => '#0369a1', + 'desc' => 'Secondary business communications gateway.', + 'tag' => 'Microsoft 365' + ] ); - $devRole = Role::updateOrCreate( - ['name' => 'Developer'], - ['description' => 'Writes code and builds features.'] + $todo = App::firstOrCreate( + ['name' => 'Microsoft To-Do'], + [ + 'url' => 'https://outlook.cloud.microsoft/host/0d5c91ee-5be2-4b79-81ed-23e6c4580427/ToDoId', + 'icon_svg' => 'outlook', + 'color' => '#2563eb', + 'desc' => 'Organize, track, and complete daily lists and tasks.', + 'tag' => 'Microsoft 365' + ] ); - $internRole = Role::updateOrCreate( - ['name' => 'Intern'], - ['description' => 'Learning and assisting on project modules.'] - ); + // 4. Assign default apps/services to specific roles ONLY IF role was recently created + if ($hrRole->wasRecentlyCreated) { + $hrRole->apps()->sync([$outlookMail->id, $outlookCalendar->id, $teams->id, $keka->id, $todo->id]); + } - $hrRole = Role::updateOrCreate( - ['name' => 'HR Manager'], - ['description' => 'Handles recruitment, payroll, and employee relations.'] - ); + if ($devRole->wasRecentlyCreated) { + $devRole->apps()->sync([$outlookMail->id, $outlookCalendar->id, $teams->id, $git->id, $todo->id]); + } - // 4. Assign apps/services to specific roles - // HR has access to Outlook, Teams, and Keka - $hrRole->apps()->sync([$outlook->id, $teams->id, $keka->id]); + if ($leadRole->wasRecentlyCreated) { + $leadRole->apps()->sync([$outlookMail->id, $outlookCalendar->id, $teams->id, $git->id, $todo->id]); + } - // Developers have access to Outlook and Teams - $devRole->apps()->sync([$outlook->id, $teams->id]); + if ($pmRole->wasRecentlyCreated) { + $pmRole->apps()->sync([$outlookMail->id, $outlookCalendar->id, $teams->id, $todo->id]); + } - // Team Leads have access to Outlook and Teams - $leadRole->apps()->sync([$outlook->id, $teams->id]); + if ($salesRole->wasRecentlyCreated) { + $salesRole->apps()->sync([$teams->id, $convexCrm->id, $demoCrm->id]); + } - // Project Managers have access to Outlook and Teams - $pmRole->apps()->sync([$outlook->id, $teams->id]); + if ($internRole->wasRecentlyCreated) { + $internRole->apps()->sync([$teams->id]); + } - // Sales Team has access to Teams - $salesRole->apps()->sync([$teams->id]); - - // Interns have access to Teams (no Outlook, no Keka) - $internRole->apps()->sync([$teams->id]); - - // 5. Seed default standard users and assign roles - // John Doe (Developer & Team Lead) - Test multiple roles - $user1 = User::updateOrCreate( + // 5. Seed default standard users and assign roles (Preserve if already exists) + $user1 = User::firstOrCreate( ['email' => 'user@company.com'], [ 'name' => 'John Doe User', @@ -123,10 +217,11 @@ public function run(): void 'microsoft_id' => 'mock-microsoft-id-123', ] ); - $user1->roles()->sync([$devRole->id, $leadRole->id]); + if ($user1->wasRecentlyCreated) { + $user1->roles()->sync([$devRole->id, $leadRole->id]); + } - // Jane Smith (HR Manager) - $user2 = User::updateOrCreate( + $user2 = User::firstOrCreate( ['email' => 'hr@company.com'], [ 'name' => 'Jane Smith HR', @@ -134,24 +229,25 @@ public function run(): void 'microsoft_id' => 'mock-microsoft-id-456', ] ); - $user2->roles()->sync([$hrRole->id]); + if ($user2->wasRecentlyCreated) { + $user2->roles()->sync([$hrRole->id]); + } - // 6. Seed user-specific overrides for testing - // John Doe (Developer & Team Lead - has Outlook and Teams via roles) - // Scenario A: Revoke Outlook for John Doe (even though Developer role grants it) - UserAppOverride::updateOrCreate( - ['user_id' => $user1->id, 'app_id' => $outlook->id], - ['type' => 'deny'] - ); + // 6. Seed user-specific overrides ONLY IF override is recently created + if ($user1->wasRecentlyCreated) { + UserAppOverride::firstOrCreate( + ['user_id' => $user1->id, 'app_id' => $outlookMail->id], + ['type' => 'deny'] + ); - // Scenario B: Add Keka HR as an extra service for John Doe (irrespective of Developer role) - UserAppOverride::updateOrCreate( - ['user_id' => $user1->id, 'app_id' => $keka->id], - ['type' => 'allow'] - ); + UserAppOverride::firstOrCreate( + ['user_id' => $user1->id, 'app_id' => $keka->id], + ['type' => 'allow'] + ); + } // Seed default role setting - \App\Models\Setting::updateOrCreate( + Setting::firstOrCreate( ['key' => 'default_role'], ['value' => 'Developer'] ); diff --git a/public/Screenshot_11.png b/public/Screenshot_11.png new file mode 100644 index 0000000..3152f67 Binary files /dev/null and b/public/Screenshot_11.png differ diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index f1d5ac3..5d4aee2 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -12,11 +12,18 @@ + + + + + + +