Car-Repairs-Shop/app/Console/Commands/SetupCustomerRoles.php
sackey cbae4564b9
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
Add customer portal views for dashboard, estimates, invoices, vehicles, and work orders
- Implemented dashboard view with vehicle stats, active services, recent activity, and upcoming appointments.
- Created estimates view with filtering options and a list of service estimates.
- Developed invoices view to manage service invoices and payment history with filtering.
- Added vehicles view to display registered vehicles and their details.
- Built work orders view to track the progress of vehicle services with filtering and detailed information.
2025-08-08 09:56:26 +00:00

46 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
use App\Models\Role;
class SetupCustomerRoles extends Command
{
protected $signature = 'setup:customer-roles';
protected $description = 'Assign customer_portal role to customer users';
public function handle()
{
// Find the customer_portal role
$customerRole = Role::where('name', 'customer_portal')->first();
if (!$customerRole) {
$this->error('customer_portal role not found!');
return 1;
}
// Find customer users
$customerEmails = ['customer@example.com', 'testcustomer@example.com'];
$users = User::whereIn('email', $customerEmails)->get();
foreach ($users as $user) {
if (!$user->hasRole('customer_portal')) {
$user->roles()->attach($customerRole->id, [
'is_active' => true,
'assigned_at' => now(),
'branch_code' => null,
'created_at' => now(),
'updated_at' => now()
]);
$this->info("Assigned customer_portal role to: {$user->email}");
} else {
$this->info("User {$user->email} already has customer_portal role");
}
}
return 0;
}
}