c9cb3560ef
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
54 lines
2.0 KiB
PHP
54 lines
2.0 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
Schema::create('leads', function (Blueprint $t) {
|
|
$t->id();
|
|
$t->foreignId('company_id')->constrained()->cascadeOnDelete();
|
|
$t->foreignId('client_id')->nullable()->constrained()->nullOnDelete();
|
|
$t->foreignId('vehicle_id')->nullable()->constrained()->nullOnDelete();
|
|
|
|
$t->string('name');
|
|
$t->string('phone');
|
|
$t->string('email')->nullable();
|
|
$t->string('car')->nullable();
|
|
$t->string('model')->nullable();
|
|
$t->text('message')->nullable();
|
|
|
|
$t->string('source')->nullable(); // call/site/telegram/whatsapp/instagram/google/...
|
|
$t->string('marketing_channel')->nullable();
|
|
$t->string('utm_source')->nullable();
|
|
$t->string('utm_medium')->nullable();
|
|
$t->string('utm_campaign')->nullable();
|
|
$t->string('utm_term')->nullable();
|
|
$t->string('utm_content')->nullable();
|
|
|
|
$t->string('status')->default('new'); // new/contacted/no_answer/scheduled/converted/lost
|
|
$t->decimal('budget', 12, 2)->nullable();
|
|
$t->foreignId('assigned_to')->nullable()->constrained('users')->nullOnDelete();
|
|
$t->foreignId('deal_id')->nullable(); // set when converted
|
|
$t->timestamp('contacted_at')->nullable();
|
|
$t->timestamp('converted_at')->nullable();
|
|
$t->text('notes')->nullable();
|
|
|
|
$t->timestamps();
|
|
$t->softDeletes();
|
|
|
|
$t->index(['company_id', 'status']);
|
|
$t->index(['company_id', 'created_at']);
|
|
$t->index(['company_id', 'source']);
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('leads');
|
|
}
|
|
};
|