Faza 3.1: CRM core — Leads, Deals, Appointments, Settings, Widgets, Users
Spatie Permission cu teams (team_foreign_key=company_id, teams=true): - migrations create_permission_tables (model_has_roles cu company_id scope) - HasRoles trait pe User - ResolveTenant middleware setează permissions team_id la tenant.id - Seed: 7 roluri default per tenant (admin/manager/receptionist/mechanic/parts_manager/accountant/marketer) Module noi: - Leads (cereri): name, phone, car/model, source, UTM, status, budget, assigned_to, acțiune "Convertește" → creează automat Client + Deal - Deals (pipeline): client/vehicle, stage (8 stage-uri), price, source, lost_reason - Posts + Appointments: post_id (boxă), master_id, date+time_start+time_end, status, color - UserResource (tenant): CRUD users cu role/status/locale; canViewAny doar pentru admin Custom Filament page "Setări" (tenant): - Brand & contact (display_name, city, phone, email) - Localizare (limba RO/RU/EN, currency, theme color picker) - Servicii & tarif (labor_rate) - Liste configurabile (services, cars) — păstrate în companies.settings JSON Widgets dashboard: - Tenant: StatsOverview (Clienți, Mașini, Cereri noi, Deal-uri active, Programări azi) - Central: PlatformStats (Companii total/active/trial, Expiră în 7 zile) Seed extins demo PSauto: - 3 posturi (Pod 1/2/3 cu culori) - 2 lead-uri demo (Alex Grosu Telegram, Irina Cojocaru WhatsApp) - 3 deal-uri demo (BMW done, Audi in_work, Porsche agree) - 2 programări (azi + mâine) Filament v5 fixes: - $navigationGroup type → string|UnitEnum|null (parent stricter signature) - Toate resources noi au tipurile corecte
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Central\Widgets;
|
||||
|
||||
use App\Models\Central\Company;
|
||||
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
class PlatformStats extends BaseWidget
|
||||
{
|
||||
protected static ?int $sort = 1;
|
||||
|
||||
protected function getStats(): array
|
||||
{
|
||||
$total = Company::count();
|
||||
$active = Company::where('status', 'active')->count();
|
||||
$trial = Company::where('status', 'trial')->count();
|
||||
$expiring = Company::where('status', 'active')
|
||||
->whereNotNull('active_until')
|
||||
->whereDate('active_until', '<=', now()->addDays(7))
|
||||
->count();
|
||||
|
||||
return [
|
||||
Stat::make('Companii total', $total)
|
||||
->icon('heroicon-o-building-office-2')
|
||||
->color('primary'),
|
||||
Stat::make('Active', $active)
|
||||
->icon('heroicon-o-check-circle')
|
||||
->color('success'),
|
||||
Stat::make('Trial', $trial)
|
||||
->icon('heroicon-o-clock')
|
||||
->color('warning'),
|
||||
Stat::make('Expiră în 7 zile', $expiring)
|
||||
->description($expiring > 0 ? 'Atenție!' : 'Toate ok')
|
||||
->icon('heroicon-o-exclamation-triangle')
|
||||
->color($expiring > 0 ? 'danger' : 'success'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Pages;
|
||||
|
||||
use App\Tenancy\TenantManager;
|
||||
use Filament\Forms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class Settings extends Page
|
||||
{
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-cog-6-tooth';
|
||||
|
||||
protected static ?string $navigationLabel = 'Setări';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Admin';
|
||||
|
||||
protected static ?int $navigationSort = 90;
|
||||
|
||||
protected static ?string $title = 'Setări companie';
|
||||
|
||||
protected string $view = 'filament.tenant.pages.settings';
|
||||
|
||||
public ?array $data = [];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$company = app(TenantManager::class)->current();
|
||||
$settings = (array) ($company->settings ?? []);
|
||||
|
||||
$this->data = [
|
||||
'display_name' => $company->display_name ?? $company->name,
|
||||
'city' => $company->city,
|
||||
'phone' => $company->phone,
|
||||
'email' => $company->email,
|
||||
'currency' => $settings['currency'] ?? 'MDL',
|
||||
'language' => $settings['language'] ?? 'ro',
|
||||
'theme_color' => $settings['theme_color'] ?? '#3B82F6',
|
||||
'labor_rate' => $settings['labor_rate'] ?? 400,
|
||||
'services' => isset($settings['services']) ? implode(', ', (array) $settings['services']) : '',
|
||||
'cars' => isset($settings['cars']) ? implode(', ', (array) $settings['cars']) : '',
|
||||
];
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Forms\Components\Section::make('Brand & contact')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('display_name')->label('Denumire afișată')->maxLength(120),
|
||||
Forms\Components\TextInput::make('city')->label('Oraș')->maxLength(60),
|
||||
Forms\Components\TextInput::make('phone')->label('Telefon')->tel()->maxLength(40),
|
||||
Forms\Components\TextInput::make('email')->email()->maxLength(120),
|
||||
]),
|
||||
Forms\Components\Section::make('Localizare & monedă')
|
||||
->columns(3)
|
||||
->schema([
|
||||
Forms\Components\Select::make('language')
|
||||
->label('Limbă default')
|
||||
->options(['ro' => 'Română', 'ru' => 'Русский', 'en' => 'English'])
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('currency')->label('Monedă')->maxLength(8)->required(),
|
||||
Forms\Components\ColorPicker::make('theme_color')->label('Culoare brand'),
|
||||
]),
|
||||
Forms\Components\Section::make('Servicii & tarif')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('labor_rate')->label('Tarif normo-oră')->numeric()->required(),
|
||||
]),
|
||||
Forms\Components\Section::make('Liste configurabile')
|
||||
->columns(1)
|
||||
->schema([
|
||||
Forms\Components\Textarea::make('services')
|
||||
->label('Servicii oferite (separate prin virgulă)')
|
||||
->rows(2),
|
||||
Forms\Components\Textarea::make('cars')
|
||||
->label('Mărci auto suportate (separate prin virgulă)')
|
||||
->rows(2),
|
||||
]),
|
||||
])
|
||||
->statePath('data');
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
$company = app(TenantManager::class)->current();
|
||||
|
||||
$company->update([
|
||||
'display_name' => $data['display_name'] ?? null,
|
||||
'city' => $data['city'] ?? null,
|
||||
'phone' => $data['phone'] ?? null,
|
||||
'email' => $data['email'] ?? null,
|
||||
'settings' => array_merge((array) $company->settings, [
|
||||
'language' => $data['language'] ?? 'ro',
|
||||
'currency' => $data['currency'] ?? 'MDL',
|
||||
'theme_color' => $data['theme_color'] ?? '#3B82F6',
|
||||
'labor_rate' => (float) ($data['labor_rate'] ?? 400),
|
||||
'services' => array_values(array_filter(array_map('trim', explode(',', (string) ($data['services'] ?? ''))))),
|
||||
'cars' => array_values(array_filter(array_map('trim', explode(',', (string) ($data['cars'] ?? ''))))),
|
||||
]),
|
||||
]);
|
||||
|
||||
Notification::make()->title('Setări salvate')->success()->send();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources;
|
||||
|
||||
use App\Filament\Tenant\Resources\AppointmentResource\Pages;
|
||||
use App\Models\Tenant\Appointment;
|
||||
use App\Models\Tenant\Client;
|
||||
use App\Models\Tenant\Post;
|
||||
use App\Models\Tenant\User;
|
||||
use App\Models\Tenant\Vehicle;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class AppointmentResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Appointment::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-calendar-days';
|
||||
|
||||
protected static ?string $navigationLabel = 'Calendar';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'CRM';
|
||||
|
||||
protected static ?string $modelLabel = 'programare';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'programări';
|
||||
|
||||
protected static ?int $navigationSort = 7;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Forms\Components\Section::make('Când & unde')
|
||||
->columns(3)
|
||||
->schema([
|
||||
Forms\Components\DatePicker::make('date')->label('Data')->default(today())->required(),
|
||||
Forms\Components\TimePicker::make('time_start')->label('De la')->required()->seconds(false),
|
||||
Forms\Components\TimePicker::make('time_end')->label('Până la')->required()->seconds(false),
|
||||
Forms\Components\Select::make('post_id')
|
||||
->label('Pod')
|
||||
->options(fn () => Post::where('is_active', true)->orderBy('sort_order')->pluck('name', 'id'))
|
||||
->searchable(),
|
||||
Forms\Components\Select::make('master_id')
|
||||
->label('Maistru / Mecanic')
|
||||
->options(fn () => User::pluck('name', 'id'))
|
||||
->searchable(),
|
||||
Forms\Components\Select::make('status')
|
||||
->options(Appointment::STATUSES)
|
||||
->default('scheduled')
|
||||
->required(),
|
||||
]),
|
||||
Forms\Components\Section::make('Client & Auto')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Forms\Components\Select::make('client_id')
|
||||
->label('Client')
|
||||
->options(fn () => Client::pluck('name', 'id'))
|
||||
->searchable()
|
||||
->live(),
|
||||
Forms\Components\Select::make('vehicle_id')
|
||||
->label('Auto')
|
||||
->options(fn (Forms\Get $get) => $get('client_id')
|
||||
? Vehicle::where('client_id', $get('client_id'))->pluck('plate', 'id')
|
||||
: [])
|
||||
->searchable(),
|
||||
]),
|
||||
Forms\Components\TextInput::make('title')->label('Subiect')->required()->maxLength(160),
|
||||
Forms\Components\Textarea::make('notes')->label('Notițe')->columnSpanFull()->rows(2),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('date')->label('Data')->date('d.m.Y')->sortable(),
|
||||
Tables\Columns\TextColumn::make('time_start')->label('De la')->time('H:i'),
|
||||
Tables\Columns\TextColumn::make('time_end')->label('Până la')->time('H:i'),
|
||||
Tables\Columns\TextColumn::make('post.name')->label('Pod')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('title')->label('Subiect')->searchable()->limit(40),
|
||||
Tables\Columns\TextColumn::make('client.name')->label('Client')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('vehicle.plate')->label('Auto')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('master.name')->label('Maistru')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->formatStateUsing(fn ($state) => Appointment::STATUSES[$state] ?? $state)
|
||||
->badge()
|
||||
->colors([
|
||||
'gray' => ['scheduled'],
|
||||
'warning' => ['arrived'],
|
||||
'success' => ['done'],
|
||||
'danger' => ['cancelled', 'no_show'],
|
||||
]),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\Filter::make('today')
|
||||
->label('Astăzi')
|
||||
->query(fn ($q) => $q->whereDate('date', today())),
|
||||
Tables\Filters\Filter::make('upcoming')
|
||||
->label('Viitoare')
|
||||
->query(fn ($q) => $q->where('date', '>=', today())),
|
||||
Tables\Filters\SelectFilter::make('status')->options(Appointment::STATUSES),
|
||||
Tables\Filters\SelectFilter::make('post_id')
|
||||
->label('Pod')
|
||||
->options(fn () => Post::pluck('name', 'id')),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->defaultSort('date', 'desc');
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListAppointments::route('/'),
|
||||
'create' => Pages\CreateAppointment::route('/create'),
|
||||
'edit' => Pages\EditAppointment::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\AppointmentResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\AppointmentResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateAppointment extends CreateRecord
|
||||
{
|
||||
protected static string $resource = AppointmentResource::class;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\AppointmentResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\AppointmentResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditAppointment extends EditRecord
|
||||
{
|
||||
protected static string $resource = AppointmentResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [Actions\DeleteAction::make()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\AppointmentResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\AppointmentResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListAppointments extends ListRecords
|
||||
{
|
||||
protected static string $resource = AppointmentResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [Actions\CreateAction::make()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources;
|
||||
|
||||
use App\Filament\Tenant\Resources\DealResource\Pages;
|
||||
use App\Models\Tenant\Client;
|
||||
use App\Models\Tenant\Deal;
|
||||
use App\Models\Tenant\Lead;
|
||||
use App\Models\Tenant\User;
|
||||
use App\Models\Tenant\Vehicle;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class DealResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Deal::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-funnel';
|
||||
|
||||
protected static ?string $navigationLabel = 'Pipeline';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'CRM';
|
||||
|
||||
protected static ?string $modelLabel = 'deal';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'deal-uri';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Forms\Components\Section::make('Detalii')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Forms\Components\Select::make('client_id')
|
||||
->label('Client')
|
||||
->options(fn () => Client::pluck('name', 'id'))
|
||||
->searchable()
|
||||
->required(),
|
||||
Forms\Components\Select::make('vehicle_id')
|
||||
->label('Auto')
|
||||
->options(fn (Forms\Get $get) => $get('client_id')
|
||||
? Vehicle::where('client_id', $get('client_id'))->pluck('plate', 'id')
|
||||
: [])
|
||||
->searchable(),
|
||||
Forms\Components\TextInput::make('name')->label('Subiect')->required()->maxLength(160),
|
||||
Forms\Components\TextInput::make('price')->label('Valoare')->numeric()->default(0),
|
||||
Forms\Components\Select::make('stage')
|
||||
->options(Deal::STAGES)
|
||||
->default('new')
|
||||
->required(),
|
||||
Forms\Components\Select::make('source')
|
||||
->options(Lead::SOURCES)
|
||||
->searchable(),
|
||||
Forms\Components\Select::make('assigned_to')
|
||||
->label('Responsabil')
|
||||
->options(fn () => User::pluck('name', 'id'))
|
||||
->searchable(),
|
||||
]),
|
||||
Forms\Components\Textarea::make('note')->label('Notițe')->columnSpanFull()->rows(3),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->label('#')->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')->label('Subiect')->searchable()->limit(40),
|
||||
Tables\Columns\TextColumn::make('client.name')->label('Client')->searchable(),
|
||||
Tables\Columns\TextColumn::make('vehicle.plate')->label('Auto')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('stage')
|
||||
->formatStateUsing(fn ($state) => Deal::STAGES[$state] ?? $state)
|
||||
->badge()
|
||||
->colors([
|
||||
'gray' => ['new'],
|
||||
'info' => ['contact', 'agree'],
|
||||
'warning' => ['scheduled', 'arrived', 'in_work'],
|
||||
'success' => ['done'],
|
||||
'danger' => ['lost'],
|
||||
]),
|
||||
Tables\Columns\TextColumn::make('price')->money('MDL')->sortable(),
|
||||
Tables\Columns\TextColumn::make('source')->label('Sursă')->formatStateUsing(fn ($state) => Lead::SOURCES[$state] ?? $state)->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('assignedTo.name')->label('Responsabil')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('created_at')->date()->sortable(),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('stage')->options(Deal::STAGES),
|
||||
Tables\Filters\SelectFilter::make('assigned_to')
|
||||
->label('Responsabil')
|
||||
->options(fn () => User::pluck('name', 'id')),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc');
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListDeals::route('/'),
|
||||
'create' => Pages\CreateDeal::route('/create'),
|
||||
'edit' => Pages\EditDeal::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\DealResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\DealResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateDeal extends CreateRecord
|
||||
{
|
||||
protected static string $resource = DealResource::class;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\DealResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\DealResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditDeal extends EditRecord
|
||||
{
|
||||
protected static string $resource = DealResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [Actions\DeleteAction::make()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\DealResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\DealResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListDeals extends ListRecords
|
||||
{
|
||||
protected static string $resource = DealResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [Actions\CreateAction::make()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources;
|
||||
|
||||
use App\Filament\Tenant\Resources\LeadResource\Pages;
|
||||
use App\Models\Tenant\Lead;
|
||||
use App\Models\Tenant\User;
|
||||
use Filament\Forms;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class LeadResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Lead::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-inbox-arrow-down';
|
||||
|
||||
protected static ?string $navigationLabel = 'Cereri';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'CRM';
|
||||
|
||||
protected static ?string $modelLabel = 'cerere';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'cereri';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Forms\Components\Section::make('Contact')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->label('Nume')->required()->maxLength(120),
|
||||
Forms\Components\TextInput::make('phone')->label('Telefon')->tel()->required()->maxLength(40),
|
||||
Forms\Components\TextInput::make('email')->email()->maxLength(120),
|
||||
Forms\Components\Select::make('status')
|
||||
->options(Lead::STATUSES)
|
||||
->default('new')
|
||||
->required(),
|
||||
]),
|
||||
Forms\Components\Section::make('Auto')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('car')->label('Marca')->maxLength(60),
|
||||
Forms\Components\TextInput::make('model')->maxLength(60),
|
||||
]),
|
||||
Forms\Components\Textarea::make('message')->label('Mesaj client')->columnSpanFull()->rows(3),
|
||||
Forms\Components\Section::make('Sursă & Atribuire')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Forms\Components\Select::make('source')
|
||||
->options(Lead::SOURCES)
|
||||
->searchable()
|
||||
->default('manual'),
|
||||
Forms\Components\Select::make('assigned_to')
|
||||
->label('Responsabil')
|
||||
->options(fn () => User::pluck('name', 'id'))
|
||||
->searchable(),
|
||||
Forms\Components\TextInput::make('budget')->label('Buget')->numeric(),
|
||||
]),
|
||||
Forms\Components\Section::make('Marketing (UTM)')
|
||||
->collapsed()
|
||||
->columns(2)
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('utm_source'),
|
||||
Forms\Components\TextInput::make('utm_medium'),
|
||||
Forms\Components\TextInput::make('utm_campaign'),
|
||||
Forms\Components\TextInput::make('utm_term'),
|
||||
Forms\Components\TextInput::make('utm_content'),
|
||||
]),
|
||||
Forms\Components\Textarea::make('notes')->label('Notițe interne')->columnSpanFull()->rows(2),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('created_at')->label('Data')->dateTime('d.m.Y H:i')->sortable(),
|
||||
Tables\Columns\TextColumn::make('name')->searchable()->sortable(),
|
||||
Tables\Columns\TextColumn::make('phone')->copyable()->searchable(),
|
||||
Tables\Columns\TextColumn::make('car')->label('Auto')->formatStateUsing(fn ($state, $record) => trim($state . ' ' . ($record->model ?? ''))),
|
||||
Tables\Columns\TextColumn::make('source')->label('Sursă')->formatStateUsing(fn ($state) => Lead::SOURCES[$state] ?? $state)->badge(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->formatStateUsing(fn ($state) => Lead::STATUSES[$state] ?? $state)
|
||||
->badge()
|
||||
->colors([
|
||||
'gray' => ['new'],
|
||||
'warning' => ['contacted', 'no_answer'],
|
||||
'info' => ['scheduled'],
|
||||
'success' => ['converted'],
|
||||
'danger' => ['lost'],
|
||||
]),
|
||||
Tables\Columns\TextColumn::make('assignedTo.name')->label('Responsabil')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('budget')->money('MDL')->placeholder('—'),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('status')->options(Lead::STATUSES),
|
||||
Tables\Filters\SelectFilter::make('source')->options(Lead::SOURCES),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\Action::make('convert')
|
||||
->label('Convertește')
|
||||
->icon('heroicon-m-arrow-right-circle')
|
||||
->color('success')
|
||||
->visible(fn (Lead $r) => $r->status !== 'converted')
|
||||
->requiresConfirmation()
|
||||
->action(function (Lead $r) {
|
||||
$deal = $r->convert();
|
||||
Notification::make()
|
||||
->title('Convertit în deal #' . $deal->id)
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc');
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListLeads::route('/'),
|
||||
'create' => Pages\CreateLead::route('/create'),
|
||||
'edit' => Pages\EditLead::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\LeadResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\LeadResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateLead extends CreateRecord
|
||||
{
|
||||
protected static string $resource = LeadResource::class;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\LeadResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\LeadResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditLead extends EditRecord
|
||||
{
|
||||
protected static string $resource = LeadResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [Actions\DeleteAction::make()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\LeadResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\LeadResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListLeads extends ListRecords
|
||||
{
|
||||
protected static string $resource = LeadResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [Actions\CreateAction::make()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources;
|
||||
|
||||
use App\Filament\Tenant\Resources\UserResource\Pages;
|
||||
use App\Models\Tenant\User;
|
||||
use Filament\Forms;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserResource extends Resource
|
||||
{
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-user-group';
|
||||
|
||||
protected static ?string $navigationLabel = 'Utilizatori';
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Admin';
|
||||
|
||||
protected static ?string $modelLabel = 'utilizator';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'utilizatori';
|
||||
|
||||
protected static ?int $navigationSort = 80;
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
$u = auth()->user();
|
||||
return $u && $u->role === 'admin';
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Forms\Components\Section::make('Identitate')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->label('Nume')->required()->maxLength(120),
|
||||
Forms\Components\TextInput::make('email')->email()->required()->maxLength(120),
|
||||
Forms\Components\TextInput::make('phone')->tel()->maxLength(40),
|
||||
Forms\Components\Select::make('locale')
|
||||
->options(['ro' => 'Română', 'ru' => 'Русский', 'en' => 'English'])
|
||||
->default('ro'),
|
||||
]),
|
||||
Forms\Components\Section::make('Acces')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Forms\Components\Select::make('role')
|
||||
->label('Rol primar')
|
||||
->options([
|
||||
'admin' => 'Administrator',
|
||||
'manager' => 'Manager',
|
||||
'receptionist' => 'Recepție',
|
||||
'mechanic' => 'Mecanic',
|
||||
'parts_manager' => 'Magazioner piese',
|
||||
'accountant' => 'Contabil',
|
||||
'marketer' => 'Marketing',
|
||||
])
|
||||
->required()
|
||||
->default('mechanic'),
|
||||
Forms\Components\Select::make('status')
|
||||
->options(['active' => 'Activ', 'inactive' => 'Inactiv', 'blocked' => 'Blocat'])
|
||||
->default('active')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('password')
|
||||
->label('Parolă')
|
||||
->password()
|
||||
->required(fn (string $context) => $context === 'create')
|
||||
->dehydrated(fn ($state) => filled($state))
|
||||
->dehydrateStateUsing(fn ($state) => Hash::make($state))
|
||||
->minLength(6)
|
||||
->helperText('La editare lasă gol pentru a păstra parola actuală.'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('name')->searchable()->sortable(),
|
||||
Tables\Columns\TextColumn::make('email')->searchable()->copyable(),
|
||||
Tables\Columns\TextColumn::make('phone')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('role')->badge(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->badge()
|
||||
->colors([
|
||||
'success' => ['active'],
|
||||
'warning' => ['inactive'],
|
||||
'danger' => ['blocked'],
|
||||
]),
|
||||
Tables\Columns\TextColumn::make('last_login_at')->dateTime()->placeholder('—')->toggleable(),
|
||||
Tables\Columns\TextColumn::make('created_at')->date()->sortable()->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('role')->options([
|
||||
'admin' => 'Admin', 'manager' => 'Manager', 'receptionist' => 'Recepție',
|
||||
'mechanic' => 'Mecanic', 'parts_manager' => 'Magazie', 'accountant' => 'Contabil', 'marketer' => 'Marketing',
|
||||
]),
|
||||
Tables\Filters\SelectFilter::make('status')->options([
|
||||
'active' => 'Activ', 'inactive' => 'Inactiv', 'blocked' => 'Blocat',
|
||||
]),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
])
|
||||
->defaultSort('created_at', 'desc');
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListUsers::route('/'),
|
||||
'create' => Pages\CreateUser::route('/create'),
|
||||
'edit' => Pages\EditUser::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\UserResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\UserResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\UserResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\UserResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditUser extends EditRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [Actions\DeleteAction::make()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Resources\UserResource\Pages;
|
||||
|
||||
use App\Filament\Tenant\Resources\UserResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUsers extends ListRecords
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [Actions\CreateAction::make()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tenant\Widgets;
|
||||
|
||||
use App\Models\Tenant\Appointment;
|
||||
use App\Models\Tenant\Client;
|
||||
use App\Models\Tenant\Deal;
|
||||
use App\Models\Tenant\Lead;
|
||||
use App\Models\Tenant\Vehicle;
|
||||
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
class StatsOverview extends BaseWidget
|
||||
{
|
||||
protected static ?int $sort = 1;
|
||||
|
||||
protected function getStats(): array
|
||||
{
|
||||
$newLeads = Lead::where('status', 'new')->count();
|
||||
$openDeals = Deal::whereNotIn('stage', ['done', 'lost'])->count();
|
||||
$todayAppointments = Appointment::whereDate('date', today())->count();
|
||||
|
||||
return [
|
||||
Stat::make('Clienți', Client::count())
|
||||
->description('Total în baza de date')
|
||||
->icon('heroicon-o-users')
|
||||
->color('primary'),
|
||||
|
||||
Stat::make('Mașini', Vehicle::count())
|
||||
->description('Total înregistrate')
|
||||
->icon('heroicon-o-truck')
|
||||
->color('info'),
|
||||
|
||||
Stat::make('Cereri noi', $newLeads)
|
||||
->description('De procesat')
|
||||
->icon('heroicon-o-inbox-arrow-down')
|
||||
->color($newLeads > 0 ? 'warning' : 'success'),
|
||||
|
||||
Stat::make('Deal-uri active', $openDeals)
|
||||
->description('În pipeline')
|
||||
->icon('heroicon-o-funnel')
|
||||
->color('primary'),
|
||||
|
||||
Stat::make('Programări azi', $todayAppointments)
|
||||
->description(today()->format('d.m.Y'))
|
||||
->icon('heroicon-o-calendar')
|
||||
->color('success'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,12 @@ class ResolveTenant
|
||||
app(TenantManager::class)->setCurrent($company);
|
||||
$request->attributes->set('tenant', $company);
|
||||
|
||||
// Tell Spatie Permission to scope roles to this company.
|
||||
if (function_exists('app')) {
|
||||
app(\Spatie\Permission\PermissionRegistrar::class)
|
||||
->setPermissionsTeamId($company->id);
|
||||
}
|
||||
|
||||
if ($required === 'required' && ! app(TenantManager::class)->isResolved()) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tenant;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Appointment extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
public const STATUSES = [
|
||||
'scheduled' => 'Programat',
|
||||
'arrived' => 'Sosit',
|
||||
'done' => 'Finalizat',
|
||||
'cancelled' => 'Anulat',
|
||||
'no_show' => 'Neprezentat',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'company_id', 'post_id', 'client_id', 'vehicle_id', 'master_id', 'deal_id',
|
||||
'date', 'time_start', 'time_end',
|
||||
'title', 'color', 'status', 'notes',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date' => 'date',
|
||||
];
|
||||
|
||||
public function post(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Post::class);
|
||||
}
|
||||
|
||||
public function client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
public function vehicle(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Vehicle::class);
|
||||
}
|
||||
|
||||
public function master(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'master_id');
|
||||
}
|
||||
|
||||
public function deal(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Deal::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tenant;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Deal extends Model
|
||||
{
|
||||
use BelongsToTenant, SoftDeletes;
|
||||
|
||||
public const STAGES = [
|
||||
'new' => 'Nou',
|
||||
'contact' => 'Contact',
|
||||
'agree' => 'Aprobare',
|
||||
'scheduled' => 'Programat',
|
||||
'arrived' => 'Sosit',
|
||||
'in_work' => 'În lucru',
|
||||
'done' => 'Finalizat',
|
||||
'lost' => 'Pierdut',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'company_id', 'client_id', 'vehicle_id',
|
||||
'name', 'price', 'stage', 'source', 'note',
|
||||
'assigned_to', 'won_at', 'lost_at', 'lost_reason',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'price' => 'decimal:2',
|
||||
'won_at' => 'datetime',
|
||||
'lost_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
public function vehicle(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Vehicle::class);
|
||||
}
|
||||
|
||||
public function assignedTo(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'assigned_to');
|
||||
}
|
||||
|
||||
public function isOpen(): bool
|
||||
{
|
||||
return ! in_array($this->stage, ['done', 'lost'], true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tenant;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Lead extends Model
|
||||
{
|
||||
use BelongsToTenant, SoftDeletes;
|
||||
|
||||
public const STATUSES = [
|
||||
'new' => 'Nou',
|
||||
'contacted' => 'Contactat',
|
||||
'no_answer' => 'Fără răspuns',
|
||||
'scheduled' => 'Programat',
|
||||
'converted' => 'Convertit',
|
||||
'lost' => 'Pierdut',
|
||||
];
|
||||
|
||||
public const SOURCES = [
|
||||
'manual' => 'Manual',
|
||||
'call' => 'Apel',
|
||||
'site' => 'Site',
|
||||
'telegram' => 'Telegram',
|
||||
'whatsapp' => 'WhatsApp',
|
||||
'viber' => 'Viber',
|
||||
'facebook' => 'Facebook',
|
||||
'instagram' => 'Instagram',
|
||||
'tiktok' => 'TikTok',
|
||||
'google' => 'Google',
|
||||
'google_maps' => 'Google Maps',
|
||||
'seo' => 'SEO',
|
||||
'recommend' => 'Recomandare',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'company_id', 'client_id', 'vehicle_id',
|
||||
'name', 'phone', 'email', 'car', 'model', 'message',
|
||||
'source', 'marketing_channel',
|
||||
'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',
|
||||
'status', 'budget', 'assigned_to', 'deal_id',
|
||||
'contacted_at', 'converted_at', 'notes',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'budget' => 'decimal:2',
|
||||
'contacted_at' => 'datetime',
|
||||
'converted_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function client(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
public function vehicle(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Vehicle::class);
|
||||
}
|
||||
|
||||
public function assignedTo(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'assigned_to');
|
||||
}
|
||||
|
||||
public function deal(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Deal::class);
|
||||
}
|
||||
|
||||
/** Convert lead → client + deal (idempotent if already converted). */
|
||||
public function convert(?array $dealAttrs = null): Deal
|
||||
{
|
||||
if ($this->deal_id) {
|
||||
return $this->deal;
|
||||
}
|
||||
|
||||
$client = $this->client_id
|
||||
? $this->client
|
||||
: Client::firstOrCreate(
|
||||
['company_id' => $this->company_id, 'phone' => $this->phone],
|
||||
['type' => 'individual', 'name' => $this->name, 'email' => $this->email, 'source' => $this->source]
|
||||
);
|
||||
|
||||
$deal = Deal::create(array_merge([
|
||||
'company_id' => $this->company_id,
|
||||
'client_id' => $client->id,
|
||||
'name' => trim(($this->car ?? '') . ' ' . ($this->model ?? '')) ?: $this->name,
|
||||
'price' => $this->budget,
|
||||
'stage' => 'new',
|
||||
'source' => $this->source,
|
||||
'note' => $this->message,
|
||||
'assigned_to' => $this->assigned_to,
|
||||
], $dealAttrs ?? []));
|
||||
|
||||
$this->update([
|
||||
'client_id' => $client->id,
|
||||
'deal_id' => $deal->id,
|
||||
'status' => 'converted',
|
||||
'converted_at' => now(),
|
||||
]);
|
||||
|
||||
return $deal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Tenant;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
protected $fillable = ['company_id', 'name', 'color', 'is_active', 'sort_order'];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
public function appointments(): HasMany
|
||||
{
|
||||
return $this->hasMany(Appointment::class);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
/**
|
||||
* Tenant-bound user. Belongs to exactly one Company.
|
||||
@@ -17,7 +18,10 @@ use Illuminate\Notifications\Notifiable;
|
||||
*/
|
||||
class User extends Authenticatable implements FilamentUser
|
||||
{
|
||||
use BelongsToTenant, HasFactory, Notifiable, SoftDeletes;
|
||||
use BelongsToTenant, HasFactory, HasRoles, Notifiable, SoftDeletes;
|
||||
|
||||
/** Spatie Permission scope key matches the team_foreign_key (company_id). */
|
||||
protected $guard_name = 'web';
|
||||
|
||||
protected $fillable = [
|
||||
'company_id', 'name', 'email', 'phone', 'avatar_url',
|
||||
|
||||
@@ -43,6 +43,9 @@ class CentralPanelProvider extends PanelProvider
|
||||
Dashboard::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Central/Widgets'), for: 'App\\Filament\\Central\\Widgets')
|
||||
->widgets([
|
||||
\App\Filament\Central\Widgets\PlatformStats::class,
|
||||
])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
|
||||
@@ -42,6 +42,9 @@ class TenantPanelProvider extends PanelProvider
|
||||
Dashboard::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Tenant/Widgets'), for: 'App\\Filament\\Tenant\\Widgets')
|
||||
->widgets([
|
||||
\App\Filament\Tenant\Widgets\StatsOverview::class,
|
||||
])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
|
||||
Reference in New Issue
Block a user