Bladeren bron

Merge branch 'master' of http://host.webmagistri.biz:3000/parisio/easia into HEAD

ferrari 4 maanden geleden
bovenliggende
commit
d20096a09b
47 gewijzigde bestanden met toevoegingen van 1420 en 16 verwijderingen
  1. 26 0
      app/Console/Commands/MigrateMaster.php
  2. 30 0
      app/Console/Commands/MigrateTenants.php
  3. 17 0
      app/Database/Migrations/MasterMigration.php
  4. 17 0
      app/Database/Migrations/TenantMigration.php
  5. 38 0
      app/Helpers/helpers.php
  6. 65 0
      app/Http/Middleware/TenantMiddleware.php
  7. 100 0
      app/Livewire/Company.php
  8. 92 0
      app/Livewire/CompanyActivity.php
  9. 23 0
      app/Livewire/CompanyRate.php
  10. 23 0
      app/Livewire/CompanyService.php
  11. 1 0
      app/Livewire/Dashboard.php
  12. 1 0
      app/Livewire/Index.php
  13. 43 0
      app/Livewire/Login.php
  14. 20 0
      app/Livewire/Onboarding.php
  15. 9 0
      app/Livewire/Registration.php
  16. 25 0
      app/Models/City.php
  17. 67 0
      app/Models/Company.php
  18. 25 0
      app/Models/CompanyActivity.php
  19. 27 0
      app/Models/CompanyRate.php
  20. 25 0
      app/Models/CompanyService.php
  21. 19 0
      app/Models/Country.php
  22. 4 1
      app/Providers/AppServiceProvider.php
  23. 24 0
      app/Providers/MigrationServiceProvider.php
  24. 253 0
      app/Services/MigrationService.php
  25. 72 0
      app/Services/MultiTenantAuthService.php
  26. 2 1
      bootstrap/app.php
  27. 4 1
      composer.json
  28. 1 0
      config/livewire.php
  29. 2 1
      database/migrations/0001_01_01_000000_create_users_table.php
  30. 2 1
      database/migrations/0001_01_01_000001_create_cache_table.php
  31. 2 1
      database/migrations/0001_01_01_000002_create_jobs_table.php
  32. 51 0
      database/migrations/2025_08_04_100000_add_fields_to_users_table.php
  33. 31 0
      database/migrations/2025_08_08_101404_create_countries_table.php
  34. 33 0
      database/migrations/2025_08_08_101413_create_cities_table.php
  35. 48 0
      database/migrations/2025_08_08_102010_create_companies_table.php
  36. 34 0
      database/migrations/2025_08_08_102231_create_company_services_table.php
  37. 34 0
      database/migrations/2025_18_08_161031_create_company_activities_table.php
  38. 36 0
      database/migrations/2025_18_08_161031_create_company_rates_table.php
  39. 9 3
      database/seeders/DatabaseSeeder.php
  40. 2 0
      resources/views/layouts/admin.blade.php
  41. 12 0
      resources/views/livewire/company.blade.php
  42. 34 0
      resources/views/livewire/company_activity.blade.php
  43. 4 0
      resources/views/livewire/company_rate.blade.php
  44. 4 0
      resources/views/livewire/company_service.blade.php
  45. 6 1
      resources/views/livewire/dashboard.blade.php
  46. 10 4
      resources/views/livewire/login.blade.php
  47. 13 2
      routes/web.php

+ 26 - 0
app/Console/Commands/MigrateMaster.php

@@ -0,0 +1,26 @@
+<?php
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use App\Services\MigrationService;
+
+class MigrateMaster extends Command
+{
+    protected $signature = 'migrate:master {--rollback} {--step=1}';
+    protected $description = 'Run migrations on master database only';
+
+    public function handle(MigrationService $migrationService)
+    {
+        if ($this->option('rollback')) {
+            $result = $migrationService->rollbackMasterMigrations($this->option('step'));
+            $this->info($result['message']);
+            $this->line($result['output']);
+        } else {
+            $result = $migrationService->runMasterMigrations();
+            $this->info($result['message']);
+            if (!empty($result['migrations'])) {
+                $this->table(['Master Migrations'], array_map(fn($m) => [$m], $result['migrations']));
+            }
+        }
+    }
+}

+ 30 - 0
app/Console/Commands/MigrateTenants.php

@@ -0,0 +1,30 @@
+<?php
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use App\Services\MigrationService;
+
+class MigrateTenants extends Command
+{
+    protected $signature = 'migrate:tenants {--rollback} {--step=1}';
+    protected $description = 'Run migrations on all tenant databases';
+
+    public function handle(MigrationService $migrationService)
+    {
+        if ($this->option('rollback')) {
+            $result = $migrationService->rollbackTenantMigrations($this->option('step'));
+        } else {
+            $result = $migrationService->runTenantMigrations();
+        }
+
+        $this->info($result['message']);
+
+        if (!empty($result['results'])) {
+            $tableData = [];
+            foreach ($result['results'] as $r) {
+                $tableData[] = [$r['tenant'], $r['status'], $r['message']];
+            }
+            $this->table(['Tenant Database', 'Status', 'Message'], $tableData);
+        }
+    }
+}

+ 17 - 0
app/Database/Migrations/MasterMigration.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Database\Migrations;
+
+use Illuminate\Database\Migrations\Migration as BaseMigration;
+
+abstract class MasterMigration extends BaseMigration
+{
+    public function getConnection()
+    {
+        return 'master';
+    }
+
+    public function isMasterMigration(): bool
+    {
+        return true;
+    }
+}

+ 17 - 0
app/Database/Migrations/TenantMigration.php

@@ -0,0 +1,17 @@
+<?php
+namespace App\Database\Migrations;
+
+use Illuminate\Database\Migrations\Migration as BaseMigration;
+
+abstract class TenantMigration extends BaseMigration
+{
+    public function getConnection()
+    {
+        return 'tenant';
+    }
+
+    public function isTenantMigration(): bool
+    {
+        return true;
+    }
+}

+ 38 - 0
app/Helpers/helpers.php

@@ -0,0 +1,38 @@
+<?php
+
+if (! function_exists('setTenant')) {
+    function setTenant()
+    {
+        $user = auth()->user();
+
+        if ($user) {
+            Log::info('Setting database connection', [
+                'database' => $user->tenant_database,
+                'username' => $user->tenant_username,
+                'password' => $user->tenant_password
+            ]);
+
+            $connection = [
+                'driver' => 'mysql',
+                'host' => '127.0.0.1',
+                'port' => '3306',
+                'database' => $user->tenant_database,
+                'username' => $user->tenant_username,
+                'password' => $user->tenant_password,
+            ];
+
+            config(['database.connections.tenant' => $connection]);
+
+            config(['database.default' => 'tenant']);
+            DB::purge('tenant');
+            DB::reconnect('tenant');
+
+            session(['currentClient' => $user->tenant_database]);
+
+            session(['db_connection' => $connection]);
+
+            Log::info('Current database after setup: ' . DB::connection()->getDatabaseName());
+            Log::info('Current default connection: ' . DB::getDefaultConnection());
+        }
+    }
+}

+ 65 - 0
app/Http/Middleware/TenantMiddleware.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+use Illuminate\Http\Request;
+use Symfony\Component\HttpFoundation\Response;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
+
+class TenantMiddleware
+{
+    /**
+     * Handle an incoming request.
+     */
+    public function handle(Request $request, Closure $next): Response
+    {
+
+        if (! $request->user()) {
+            return redirect('/');
+        }
+
+        $this->setupTenantConnection($request->user());
+
+        return $next($request);
+    }
+
+    /**
+     * Set up the tenant database connection
+     */
+    public function setupTenantConnection($user = null)
+    {
+        $user = $user ?: auth()->user();
+
+        if ($user) {
+            Log::info('Setting database connection', [
+                'database' => $user->tenant_database,
+                'username' => $user->tenant_username,
+                'password' => $user->tenant_password
+            ]);
+
+            $connection = [
+                'driver' => 'mysql',
+                'host' => '127.0.0.1',
+                'port' => '3306',
+                'database' => $user->tenant_database,
+                'username' => $user->tenant_username,
+                'password' => $user->tenant_password,
+            ];
+
+            config(['database.connections.tenant' => $connection]);
+
+            config(['database.default' => 'tenant']);
+            DB::purge('tenant');
+            DB::reconnect('tenant');
+
+            session(['currentClient' => $user->tenant_database]);
+
+            session(['db_connection' => $connection]);
+
+            Log::info('Current database after setup: ' . DB::connection()->getDatabaseName());
+            Log::info('Current default connection: ' . DB::getDefaultConnection());
+        }
+    }
+}

+ 100 - 0
app/Livewire/Company.php

@@ -0,0 +1,100 @@
+<?php
+
+namespace App\Livewire;
+
+use Livewire\Component;
+use Livewire\Attributes\Validate;
+
+class Company extends Component
+{
+
+    #[Validate('required')] 
+    public $name = '';
+    public $business_name = '';
+    public $logo = '';
+    public $phone = '';
+    public $email = '';
+    public $pec = '';
+    public $costitution_date = null;
+    public $address = '';
+    public $zip = '';
+    public $city_id = null;
+    public $country_id = null;
+    public $operational_headquarters = '';
+    public $fiscal_code = '';
+    public $vat = ''; 
+    public $sdi_code = '';
+    public $ateco_code = '';
+    public $enabled = true;
+
+    public $current_company = null;
+
+    public $is_edit = false;
+
+    public function render()
+    {
+
+        // Get Company
+        $this->current_company = \App\Models\Company::first();
+
+        if ($this->current_company != null)
+        {
+
+            $this->name = $this->current_company->name;
+            $this->business_name = $this->current_company->business_name;
+            $this->logo = $this->current_company->logo;
+            $this->phone = $this->current_company->phone;
+            $this->email = $this->current_company->email;
+            $this->pec = $this->current_company->pec;
+            $this->costitution_date = $this->current_company->pec;
+            $this->address = $this->current_company->address;
+            $this->zip = $this->current_company->zip;
+            $this->city_id = $this->current_company->city_id;
+            $this->country_id = $this->current_company->country_id;
+            $this->operational_headquarters = $this->current_company->operational_headquarters;
+            $this->fiscal_code = $this->current_company->fiscal_code;
+            $this->vat = $this->current_company-> vat;
+            $this->sdi_code = $this->current_company->sdi_code;
+            $this->ateco_code = $this->current_company->ateco_code;
+            $this->enabled = $this->current_company->enabled;
+
+        }
+
+        return view('livewire.company');
+    }
+
+    public function update()
+    {
+
+        $this->validate();
+
+        try {
+            $this->current_company->update([
+                'name' => $this->name,
+                'business_name' => $this->business_name,
+                'logo' => $this->logo,
+                'phone' => $this->phone,
+                'email' => $this->email,
+                'pec' => $this->pec,
+                'costitution_date' => $this->pec,
+                'address' => $this->address,
+                'zip' => $this->zip,
+                'city_id' => $this->city_id,
+                'country_id' => $this->country_id,
+                'operational_headquarters' => $this->operational_headquarters,
+                'fiscal_code' => $this->fiscal_code,
+                'vat' => $this-> vat,
+                'sdi_code' => $this->sdi_code,
+                'ateco_code' => $this->ateco_code,
+                'enabled' => $this->enabled,
+            ]);
+            session()->flash('success','Dato aggiornato');
+            //$this->resetFields();
+            $this->is_edit = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+
+    }
+
+}

+ 92 - 0
app/Livewire/CompanyActivity.php

@@ -0,0 +1,92 @@
+<?php
+
+namespace App\Livewire;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\DB;
+use Livewire\Attributes\Validate;
+use Livewire\Component;
+use Livewire\Attributes\Layout;
+
+class CompanyActivity extends Component
+{
+
+    public $company;
+
+    public $current_company_activity = null;
+
+    public $company_activities = [];
+
+    #[Validate('required')] 
+    public $name = '';
+    public $description = '';
+    public $enabled = 1;
+
+    public $is_edit = false;
+
+    public function resetFields(){
+        $this->name = '';
+        $this->description = '';
+        $this->enabled = 1;
+    }
+
+    public function render()
+    {
+        $this->company_activities = $this->company->activities;
+        return view('livewire.company_activity');
+    }
+
+    public function add()
+    {
+        $this->resetFields();
+        $this->is_edit = true;
+        $this->current_company_activity = null;
+    }
+
+    public function edit($id)
+    {
+        $this->resetFields();
+        $this->is_edit = true;
+        $this->current_company_activity = \App\Models\CompanyActivity::findOrFail($id);
+        $this->name = $this->current_company_activity->name;
+        $this->description = $this->current_company_activity->description;
+        $this->enabled = $this->current_company_activity->enabled == 1;
+    }
+
+    public function save()
+    {
+        $this->validate();
+        try 
+        {
+            if ($this->current_company_activity == null)
+            {
+                \App\Models\CompanyActivity::create([
+                    'company_id' => $this->company->id,
+                    'name' => $this->name,
+                    'description' => $this->description,
+                    'enabled' => $this->enabled
+                ]);
+            }
+            else
+            {
+                $this->current_company_activity->update([
+                    'name' => $this->name,
+                    'description' => $this->description,
+                    'enabled' => $this->enabled ? 1 : 0,
+                ]);
+            }
+            session()->flash('success','Dati salvati con successo');
+            $this->resetFields();
+            $this->is_edit = false;
+        } catch (\Exception $ex) {
+            session()->flash('error','Errore (' . $ex->getMessage() . ')');
+        }
+    }
+
+    public function cancel()
+    {
+        $this->resetFields();
+        $this->is_edit = false;
+        $this->current_company_activity = null;
+    }
+
+}

+ 23 - 0
app/Livewire/CompanyRate.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Livewire;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\DB;
+use Livewire\Attributes\Validate;
+use Livewire\Component;
+use Livewire\Attributes\Layout;
+
+class CompanyRate extends Component
+{
+
+    public $company;
+
+    #[Validate('required')] 
+    public $name = '';
+
+    public function render()
+    {
+        return view('livewire.company_rate');
+    }
+
+}

+ 23 - 0
app/Livewire/CompanyService.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Livewire;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\DB;
+use Livewire\Attributes\Validate;
+use Livewire\Component;
+use Livewire\Attributes\Layout;
+
+class CompanyService extends Component
+{
+
+    public $company;
+
+    #[Validate('required')] 
+    public $name = '';
+
+    public function render()
+    {
+        return view('livewire.company_service');
+    }
+
+}

+ 1 - 0
app/Livewire/Dashboard.php

@@ -6,6 +6,7 @@ use Livewire\Component;
 
 class Dashboard extends Component
 {
+
     public function render()
     {
         return view('livewire.dashboard');

+ 1 - 0
app/Livewire/Index.php

@@ -3,6 +3,7 @@
 namespace App\Livewire;
 
 use Livewire\Component;
+use Livewire\Attributes\Layout;
 
 class Index extends Component
 {

+ 43 - 0
app/Livewire/Login.php

@@ -4,12 +4,55 @@ namespace App\Livewire;
 
 use Livewire\Attributes\Layout;
 use Livewire\Component;
+use Livewire\Attributes\Layout;
 
 class Login extends Component
 {
+
+    public $email;
+    public $password;
+
+    protected $rules = [
+        'email' => 'required',
+        'password' => 'required',
+    ];
+
+    protected $messages = [
+        'email.required' => 'La mail è obbligatoria',
+        'password.required' => 'La password è obbligatoria',
+    ];
+
+    public $error = '';
+
     #[Layout('layouts.frontend')]
     public function render()
     {
         return view('livewire.login');
     }
+
+    public function login()
+    {
+
+        $this->validate();
+        
+        if (\Auth::attempt(['email' => $this->email, 'password' => $this->password])) 
+        {
+        
+            $user = \Auth::user();
+
+            /*if (!$user->first_login_completed) 
+            {
+                $user->first_login_at = now();
+                $user->save();
+
+                return redirect('/first-login');
+            }*/
+
+            return redirect()->route('dashboard');
+        } 
+        else 
+        {
+            $this->error = 'ERRORE';
+        }
+    }
 }

+ 20 - 0
app/Livewire/Onboarding.php

@@ -4,9 +4,29 @@ namespace App\Livewire;
 
 use Livewire\Attributes\Layout;
 use Livewire\Component;
+use Livewire\Attributes\Layout;
 
 class Onboarding extends Component
 {
+
+    // step 1
+    public $name;
+    public $businessName;
+    public $sector;
+    public $activity;
+    public $logo;
+
+    // step 2
+    public $calendarTypology;
+    public $slotInterval;
+    public $startHourView;
+    public $endHourView;
+
+    // step 3
+    public $slotApprovalWorkflow;
+    public $costsApprovalWorkflow;
+    public $absenceApprovalWorkflow;
+
     #[Layout('layouts.frontend')]
     public function render()
     {

+ 9 - 0
app/Livewire/Registration.php

@@ -4,9 +4,18 @@ namespace App\Livewire;
 
 use Livewire\Attributes\Layout;
 use Livewire\Component;
+use Livewire\Attributes\Layout;
 
 class Registration extends Component
 {
+
+    public $firstName;
+    public $lastName;
+    public $company;
+    public $email;
+    public $password;
+    public $passwordConfirm;
+
     #[Layout('layouts.frontend')]
     public function render()
     {

+ 25 - 0
app/Models/City.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class City extends Model
+{
+    use HasFactory;
+    use SoftDeletes;
+
+    protected $fillable = [
+        'country_id',
+        'name',
+        'enabled',
+    ];
+
+    public function country()
+    {
+        return $this->belongsTo(\App\Models\Country::class);
+    }
+
+}

+ 67 - 0
app/Models/Company.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\DB;
+
+
+class Company extends Model
+{
+    use HasFactory;
+    use SoftDeletes;
+
+    public function __construct()
+    {
+        setTenant();
+    }
+
+    protected $fillable = [
+        'name',
+        'business_name',
+        'logo',
+        'phone',
+        'email',
+        'pec',
+        'costitution_date',
+        'address',
+        'zip',
+        'city_id',
+        'country_id',
+        'operational_headquarters',
+        'fiscal_code',
+        'vat',           
+        'sdi_code',
+        'ateco_code',            
+        'enabled',
+    ];
+
+    public function country()
+    {
+        return $this->belongsTo(\App\Models\Country::class);
+    }
+
+    public function city()
+    {
+        return $this->belongsTo(\App\Models\City::class);
+    }
+
+    public function activities()
+    {
+        return $this->hasMany(\App\Models\CompanyActivity::class);
+    }
+
+    public function rates()
+    {
+        return $this->hasMany(\App\Models\CompanyActivity::class);
+    }
+
+    public function services()
+    {
+        return $this->hasMany(\App\Models\CompanyActivity::class);
+    }
+
+}

+ 25 - 0
app/Models/CompanyActivity.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class CompanyActivity extends Model
+{
+    use HasFactory;
+    use SoftDeletes;
+
+    protected $fillable = [
+        'company_id',
+        'name',
+        'description',
+        'enabled',
+    ];
+
+    public function country()
+    {
+        return $this->belongsTo(\App\Models\Company::class);
+    }
+}

+ 27 - 0
app/Models/CompanyRate.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class CompanyRate extends Model
+{
+    use HasFactory;
+    use SoftDeletes;
+
+    protected $fillable = [
+        'company_id',
+        'amount',
+        'type',
+        'group',
+        'description',
+        'enabled',
+    ];
+
+    public function country()
+    {
+        return $this->belongsTo(\App\Models\Company::class);
+    }
+}

+ 25 - 0
app/Models/CompanyService.php

@@ -0,0 +1,25 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class CompanyService extends Model
+{
+    use HasFactory;
+    use SoftDeletes;
+
+    protected $fillable = [
+        'company_id',
+        'name',
+        'description',
+        'enabled',
+    ];
+
+    public function country()
+    {
+        return $this->belongsTo(\App\Models\Company::class);
+    }
+}

+ 19 - 0
app/Models/Country.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+class Country extends Model
+{
+    use HasFactory;
+    use SoftDeletes;
+
+    protected $fillable = [
+        'name',
+        'enabled',
+    ];
+
+}

+ 4 - 1
app/Providers/AppServiceProvider.php

@@ -3,6 +3,7 @@
 namespace App\Providers;
 
 use Illuminate\Support\ServiceProvider;
+use Livewire;
 
 class AppServiceProvider extends ServiceProvider
 {
@@ -19,6 +20,8 @@ class AppServiceProvider extends ServiceProvider
      */
     public function boot(): void
     {
-        //
+        /*Livewire::addPersistentMiddleware([ 
+            App\Http\Middleware\TenantMiddleware::class,
+        ]);*/
     }
 }

+ 24 - 0
app/Providers/MigrationServiceProvider.php

@@ -0,0 +1,24 @@
+<?php
+namespace App\Providers;
+
+use Illuminate\Support\ServiceProvider;
+use App\Console\Commands\MigrateMaster;
+use App\Console\Commands\MigrateTenants;
+
+class MigrationServiceProvider extends ServiceProvider
+{
+    public function register()
+    {
+        $this->app->singleton(\App\Services\MigrationService::class);
+    }
+
+    public function boot()
+    {
+        if ($this->app->runningInConsole()) {
+            $this->commands([
+                MigrateMaster::class,
+                MigrateTenants::class,
+            ]);
+        }
+    }
+}

+ 253 - 0
app/Services/MigrationService.php

@@ -0,0 +1,253 @@
+<?php
+namespace App\Services;
+
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\File;
+use Illuminate\Support\Facades\Artisan;
+use App\Models\User;
+use App\Database\Migrations\MasterMigration;
+use App\Database\Migrations\TenantMigration;
+
+class MigrationService
+{
+    protected $masterDatabase = 'easia_master';
+
+    public function runMasterMigrations()
+    {
+        
+        $this->setupMasterConnection();
+
+        $masterMigrations = $this->getMasterMigrationFiles();
+
+        if (empty($masterMigrations)) {
+            return ['message' => 'No master migrations found.', 'migrations' => []];
+        }
+
+        // Create a temporary directory for master migrations only
+        $tempPath = storage_path('app/temp_master_migrations');
+        if (!File::exists($tempPath)) {
+            File::makeDirectory($tempPath, 0755, true);
+        }
+
+        // Copy only master migrations to temp directory
+        foreach ($masterMigrations as $migration) {
+            $source = database_path('migrations/' . $migration);
+            $destination = $tempPath . '/' . $migration;
+            File::copy($source, $destination);
+        }
+
+        try {
+            // Run migrations from temp directory
+            Artisan::call('migrate', [
+                '--database' => 'master',
+                '--path' => 'storage/app/temp_master_migrations'
+            ]);
+
+            $output = Artisan::output();
+        } finally {
+            // Clean up temp directory
+            File::deleteDirectory($tempPath);
+        }
+
+        return [
+            'message' => 'Master migrations completed successfully!',
+            'database' => $this->masterDatabase,
+            'migrations' => $masterMigrations,
+            'output' => $output
+        ];
+    }
+
+    public function runTenantMigrations()
+    {
+        $tenants = $this->getTenants();
+        $results = [];
+
+        if ($tenants->isEmpty()) {
+            return ['message' => 'No tenants found.', 'results' => []];
+        }
+
+        $tenantMigrations = $this->getTenantMigrationFiles();
+
+        if (empty($tenantMigrations)) {
+            return ['message' => 'No tenant migrations found.', 'results' => []];
+        }
+
+        // Create a temporary directory for tenant migrations only
+        $tempPath = storage_path('app/temp_tenant_migrations');
+        if (!File::exists($tempPath)) {
+            File::makeDirectory($tempPath, 0755, true);
+        }
+
+        // Copy only tenant migrations to temp directory
+        foreach ($tenantMigrations as $migration) {
+            $source = database_path('migrations/' . $migration);
+            $destination = $tempPath . '/' . $migration;
+            File::copy($source, $destination);
+        }
+
+        foreach ($tenants as $tenant) {
+            try {
+                $this->setupTenantConnection($tenant);
+
+                Artisan::call('migrate', [
+                    '--database' => 'tenant',
+                    '--path' => 'storage/app/temp_tenant_migrations'
+                ]);
+
+                $results[] = [
+                    'tenant' => $tenant->tenant_database,
+                    'status' => 'success',
+                    'message' => 'Migrations completed successfully'
+                ];
+
+            } catch (\Exception $e) {
+                $results[] = [
+                    'tenant' => $tenant->tenant_database,
+                    'status' => 'error',
+                    'message' => $e->getMessage()
+                ];
+            }
+        }
+
+        // Clean up temp directory
+        File::deleteDirectory($tempPath);
+
+        return [
+            'message' => 'Tenant migrations process completed',
+            'results' => $results
+        ];
+    }
+
+    public function rollbackMasterMigrations($steps = 1)
+    {
+        $this->setupMasterConnection();
+
+        Artisan::call('migrate:rollback', [
+            '--database' => 'master',
+            '--step' => $steps
+        ]);
+
+        return [
+            'message' => "Master database rolled back {$steps} step(s)",
+            'database' => $this->masterDatabase,
+            'output' => Artisan::output()
+        ];
+    }
+
+    public function rollbackTenantMigrations($steps = 1)
+    {
+        $tenants = $this->getTenants();
+        $results = [];
+
+        foreach ($tenants as $tenant) {
+            try {
+                $this->setupTenantConnection($tenant);
+
+                Artisan::call('migrate:rollback', [
+                    '--database' => 'tenant',
+                    '--step' => $steps
+                ]);
+
+                $results[] = [
+                    'tenant' => $tenant->tenant_database,
+                    'status' => 'success',
+                    'message' => "Rolled back {$steps} step(s)"
+                ];
+
+            } catch (\Exception $e) {
+                $results[] = [
+                    'tenant' => $tenant->tenant_database,
+                    'status' => 'error',
+                    'message' => $e->getMessage()
+                ];
+            }
+        }
+
+        return [
+            'message' => 'Tenant rollback process completed',
+            'results' => $results
+        ];
+    }
+
+    protected function setupMasterConnection()
+    {
+        config(['database.connections.master' => [
+            'driver' => 'mysql',
+            'host' => env('DB_HOST', '127.0.0.1'),
+            'port' => env('DB_PORT', '3306'),
+            'database' => $this->masterDatabase,
+            'username' => env('DB_USERNAME'),
+            'password' => env('DB_PASSWORD'),
+            'charset' => 'utf8mb4',
+            'collation' => 'utf8mb4_unicode_ci',
+            'prefix' => '',
+            'strict' => true,
+            'engine' => null,
+        ]]);
+
+        config(['database.default' => 'master']);
+        DB::purge('master');
+        DB::reconnect('master');
+    }
+
+    protected function setupTenantConnection($tenant)
+    {
+        config(['database.connections.tenant' => [
+            'driver' => 'mysql',
+            'host' => env('DB_HOST', '127.0.0.1'),
+            'port' => env('DB_PORT', '3306'),
+            'database' => $tenant->tenant_database,
+            'username' => $tenant->tenant_username,
+            'password' => $tenant->tenant_password,
+            'charset' => 'utf8mb4',
+            'collation' => 'utf8mb4_unicode_ci',
+            'prefix' => '',
+            'strict' => true,
+            'engine' => null,
+        ]]);
+
+        config(['database.default' => 'tenant']);
+        DB::purge('tenant');
+        DB::reconnect('tenant');
+    }
+
+    protected function getTenants()
+    {
+        return User::select('tenant_database', 'tenant_username', 'tenant_password')
+            ->whereNotNull('tenant_database')
+            ->distinct()
+            ->get();
+    }
+
+    protected function getMasterMigrationFiles()
+    {
+        $migrationPath = database_path('migrations');
+        $files = File::glob($migrationPath . '/*.php');
+        $masterMigrations = [];
+
+        foreach ($files as $file) {
+            $content = File::get($file);
+            if (strpos($content, 'extends MasterMigration') !== false) {
+                $masterMigrations[] = basename($file);
+            }
+        }
+
+        return $masterMigrations;
+    }
+
+    protected function getTenantMigrationFiles()
+    {
+        $migrationPath = database_path('migrations');
+        $files = File::glob($migrationPath . '/*.php');
+        $tenantMigrations = [];
+
+        foreach ($files as $file) {
+            $content = File::get($file);
+            if (strpos($content, 'extends TenantMigration') !== false) {
+                $tenantMigrations[] = basename($file);
+            }
+        }
+
+        return $tenantMigrations;
+    }
+}

+ 72 - 0
app/Services/MultiTenantAuthService.php

@@ -0,0 +1,72 @@
+<?php
+namespace App\Services;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Hash;
+class MultiTenantAuthService
+{
+    /**
+     * Authenticate user against both master and tenant databases
+     */
+    public static function authenticate($email, $password)
+    {
+        try {
+            $masterUser = DB::connection('mysql')->table('users')
+                ->where('email', $email)
+                ->first();
+
+            if (!$masterUser) {
+                Log::info('User not found in master database', ['email' => $email]);
+                return false;
+            }
+
+            if (!Hash::check($password, $masterUser->password)) {
+                Log::info('Password mismatch in master database', ['email' => $email]);
+                return false;
+            }
+
+            config(['database.connections.temp_tenant' => [
+                'driver' => 'mysql',
+                'host' => '127.0.0.1',
+                'port' => '3306',
+                'database' => $masterUser->tenant_database,
+                'username' => $masterUser->tenant_username,
+                'password' => $masterUser->tenant_password,
+            ]]);
+
+            $tenantUser = DB::connection('temp_tenant')->table('users')
+                ->where('email', $email)
+                ->first();
+
+            if (!$tenantUser) {
+                Log::info('User not found in tenant database', [
+                    'email' => $email,
+                    'tenant_db' => $masterUser->tenant_database
+                ]);
+                return false;
+            }
+
+            if (!Hash::check($password, $tenantUser->password)) {
+                Log::info('Password mismatch in tenant database', [
+                    'email' => $email,
+                    'tenant_db' => $masterUser->tenant_database
+                ]);
+                return false;
+            }
+
+            Log::info('Authentication successful for both databases', [
+                'email' => $email,
+                'tenant_db' => $masterUser->tenant_database
+            ]);
+
+            return $masterUser;
+
+        } catch (\Exception $e) {
+            Log::error('Authentication error', [
+                'email' => $email,
+                'error' => $e->getMessage()
+            ]);
+            return false;
+        }
+    }
+}

+ 2 - 1
bootstrap/app.php

@@ -3,6 +3,7 @@
 use Illuminate\Foundation\Application;
 use Illuminate\Foundation\Configuration\Exceptions;
 use Illuminate\Foundation\Configuration\Middleware;
+use App\Http\Middleware\TenantMiddleware;
 
 return Application::configure(basePath: dirname(__DIR__))
     ->withRouting(
@@ -11,7 +12,7 @@ return Application::configure(basePath: dirname(__DIR__))
         health: '/up',
     )
     ->withMiddleware(function (Middleware $middleware): void {
-        //
+        //$middleware->append(TenantMiddleware::class);
     })
     ->withExceptions(function (Exceptions $exceptions): void {
         //

+ 4 - 1
composer.json

@@ -25,7 +25,10 @@
             "App\\": "app/",
             "Database\\Factories\\": "database/factories/",
             "Database\\Seeders\\": "database/seeders/"
-        }
+        },
+        "files": [
+            "app/Helpers/helpers.php"
+        ]
     },
     "autoload-dev": {
         "psr-4": {

+ 1 - 0
config/livewire.php

@@ -157,4 +157,5 @@ return [
     */
 
     'pagination_theme' => 'tailwind',
+    
 ];

+ 2 - 1
database/migrations/0001_01_01_000000_create_users_table.php

@@ -3,8 +3,9 @@
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\Schema;
+use App\Database\Migrations\MasterMigration;
 
-return new class extends Migration
+return new class extends MasterMigration
 {
     /**
      * Run the migrations.

+ 2 - 1
database/migrations/0001_01_01_000001_create_cache_table.php

@@ -3,8 +3,9 @@
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\Schema;
+use App\Database\Migrations\MasterMigration;
 
-return new class extends Migration
+return new class extends MasterMigration
 {
     /**
      * Run the migrations.

+ 2 - 1
database/migrations/0001_01_01_000002_create_jobs_table.php

@@ -3,8 +3,9 @@
 use Illuminate\Database\Migrations\Migration;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Support\Facades\Schema;
+use App\Database\Migrations\MasterMigration;
 
-return new class extends Migration
+return new class extends MasterMigration
 {
     /**
      * Run the migrations.

+ 51 - 0
database/migrations/2025_08_04_100000_add_fields_to_users_table.php

@@ -0,0 +1,51 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Database\Migrations\MasterMigration;
+
+return new class extends MasterMigration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('users', function (Blueprint $table) {
+            $table->integer('level')->default(0);
+            $table->integer('enabled')->default(1);
+            $table->string('first_name')->nullable();
+            $table->string('last_name')->nullable();
+            $table->boolean('first_login_completed')->default(false);
+            $table->timestamp('first_login_at')->nullable();
+            $table->string('tenant_host')->nullable();
+            $table->string('tenant_database')->nullable();
+            $table->string('tenant_username')->nullable();
+            $table->string('tenant_password')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('users', function (Blueprint $table) {
+            $table->dropColumn('level');
+            $table->dropColumn('enabled');
+            $table->dropColumn('first_name');
+            $table->dropColumn('last_name');
+            $table->dropColumn('first_login_completed');
+            $table->dropColumn('first_login_at');
+            $table->dropColumn('tenant_host');
+            $table->dropColumn('tenant_database');
+            $table->dropColumn('tenant_username');
+            $table->dropColumn('tenant_password');
+        });
+    }
+};

+ 31 - 0
database/migrations/2025_08_08_101404_create_countries_table.php

@@ -0,0 +1,31 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Database\Migrations\TenantMigration;
+
+return new class extends TenantMigration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::create('countries', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->boolean('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('countries');
+    }
+};

+ 33 - 0
database/migrations/2025_08_08_101413_create_cities_table.php

@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Database\Migrations\TenantMigration;
+
+return new class extends TenantMigration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::create('cities', function (Blueprint $table) {
+            $table->id();
+            $table->unsignedBigInteger('country_id')->nullable();
+            $table->foreign('country_id')->nullable()->references('id')->on('countries')->onUpdate('cascade')->onDelete('cascade');
+            $table->string('name');
+            $table->boolean('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('cities');
+    }
+};

+ 48 - 0
database/migrations/2025_08_08_102010_create_companies_table.php

@@ -0,0 +1,48 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Database\Migrations\TenantMigration;
+
+return new class extends TenantMigration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::create('companies', function (Blueprint $table) {
+            $table->id();
+            $table->string('name');
+            $table->string('business_name')->nullable();
+            $table->string('logo')->nullable();
+            $table->string('phone')->nullable();
+            $table->string('email')->nullable();
+            $table->string('pec')->nullable();
+            $table->date('costitution_date')->nullable();
+            $table->string('address')->nullable();
+            $table->string('zip')->nullable();
+            $table->unsignedBigInteger('city_id')->nullable();
+            $table->foreign('city_id')->nullable()->references('id')->on('cities')->onUpdate('cascade')->onDelete('cascade');
+            $table->unsignedBigInteger('country_id')->nullable();
+            $table->foreign('country_id')->nullable()->references('id')->on('countries')->onUpdate('cascade')->onDelete('cascade');
+            $table->string('operational_headquarters')->nullable();
+            $table->string('fiscal_code')->nullable();
+            $table->string('vat')->nullable();           
+            $table->string('sdi_code')->nullable();
+            $table->string('ateco_code')->nullable();            
+            $table->boolean('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('companies');
+    }
+};

+ 34 - 0
database/migrations/2025_08_08_102231_create_company_services_table.php

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Database\Migrations\TenantMigration;
+
+return new class extends TenantMigration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::create('company_services', function (Blueprint $table) {
+            $table->id();
+            $table->unsignedBigInteger('company_id')->nullable();
+            $table->foreign('company_id')->nullable()->references('id')->on('companies')->onUpdate('cascade')->onDelete('cascade');
+            $table->string('name');
+            $table->text('description')->nullable();
+            $table->boolean('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('company_services');
+    }
+};

+ 34 - 0
database/migrations/2025_18_08_161031_create_company_activities_table.php

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Database\Migrations\TenantMigration;
+
+return new class extends TenantMigration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::create('company_activities', function (Blueprint $table) {
+            $table->id();
+            $table->unsignedBigInteger('company_id')->nullable();
+            $table->foreign('company_id')->nullable()->references('id')->on('companies')->onUpdate('cascade')->onDelete('cascade');
+            $table->string('name');
+            $table->text('description')->nullable();
+            $table->boolean('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('company_activities');
+    }
+};

+ 36 - 0
database/migrations/2025_18_08_161031_create_company_rates_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Database\Migrations\TenantMigration;
+
+return new class extends TenantMigration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::create('company_rates', function (Blueprint $table) {
+            $table->id();
+            $table->unsignedBigInteger('company_id')->nullable();
+            $table->foreign('company_id')->nullable()->references('id')->on('companies')->onUpdate('cascade')->onDelete('cascade');
+            $table->decimal('amount', total: 8, places: 2);
+            $table->string('type')->nullable();
+            $table->string('group')->nullable();
+            $table->text('description')->nullable();
+            $table->boolean('enabled')->default(1);
+            $table->softDeletes();
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('company_rates');
+    }
+};

+ 9 - 3
database/seeders/DatabaseSeeder.php

@@ -15,9 +15,15 @@ class DatabaseSeeder extends Seeder
     {
         // User::factory(10)->create();
 
-        User::factory()->create([
-            'name' => 'Test User',
-            'email' => 'test@example.com',
+        \App\Models\User::factory()->create([
+            'name' => 'Easia',
+            'email' => 'easia@easia.com',
+            'password' => bcrypt('easia'),
+            'level' => 1,
+            'tenant_host' => '127.0.0.1',
+            'tenant_database' => 'easia_tenant',
+            'tenant_username' => 'root',
+            'tenant_password' => '_brUce80!'
         ]);
     }
 }

+ 2 - 0
resources/views/layouts/admin.blade.php

@@ -56,6 +56,8 @@
 			<div class="loader"><span></span><span></span><span></span><span></span><span></span></div>
 		</div>
 
+		{{ $slot }}
+
 		@livewireScripts
 
 		<!-- jquery-->

+ 12 - 0
resources/views/livewire/company.blade.php

@@ -0,0 +1,12 @@
+<div>
+    COMPANY
+    <br>
+    {{$name}}
+    <br><br>
+    <livewire:company-service :company="$current_company"/>
+    <br><br>
+    <livewire:company-rate :company="$current_company"/>
+    <br><br>
+    <livewire:company-activity :company="$current_company"/>
+    <br><br>
+</div>

+ 34 - 0
resources/views/livewire/company_activity.blade.php

@@ -0,0 +1,34 @@
+<div>
+    COMPANY activity
+    <br>    
+    @if($is_edit)
+        Nome<br>
+        <input type="text" wire:model="name"><br>
+        @error('name')
+            {{ $message }}
+        @enderror
+        <br>
+        Descrizione<br>
+        <input type="text" wire:model="description"><br><br>
+        Enable<br>
+        <input type="checkbox" wire:model="enabled"><br><br>
+        <a wire:click="save()">Salva</a>
+        <a wire:click="cancel()">Annulla</a>
+    @else
+        <table border="1">
+            <tr>
+                <td>Nome</td>
+                <td>
+
+                </td>
+            </tr>
+            @foreach($company_activities as $c)
+                <tr>
+                    <td>{{$c->name}}</td>
+                    <td><a wire:click="edit({{$c->id}})">Modifica</a></td>
+                </tr>
+            @endforeach
+        </table>
+        <a wire:click="add()">Aggiungi</a>
+    @endif
+</div>

+ 4 - 0
resources/views/livewire/company_rate.blade.php

@@ -0,0 +1,4 @@
+<div>
+    COMPANY rate
+    <br>    
+</div>

+ 4 - 0
resources/views/livewire/company_service.blade.php

@@ -0,0 +1,4 @@
+<div>
+    COMPANY service
+    <br>    
+</div>

+ 6 - 1
resources/views/livewire/dashboard.blade.php

@@ -1 +1,6 @@
-<div>dashboard</div>
+<div>
+    DASHBOARD
+    <ul>
+        <li><a href="{{ route('company') }}">Company</li>
+    </ul>
+</div>

+ 10 - 4
resources/views/livewire/login.blade.php

@@ -6,19 +6,25 @@
                     <div class="login-main bg-primary d-flex justify-content-center">
                         <div class="login-inner w-100">
                             <img class="d-block img-fluid m-auto mb-5 form-logo" src="/assets/images/logo_white.png" alt="logo" />
-                            <form class="theme-form w-100" name="login" method="POST" action="#">
+                            <form class="theme-form" name="login" method="POST" action="#">
                                 <div class="row">
                                     <div class="col-md-12 mb-3">
                                         <div class="form-group">
                                             <label for="email">Email</label>
-                                            <input class="form-control input-white" id="email" name="email" type="email" required="" placeholder="Inserisci" />
+                                            <input class="form-control input-white @error('email') is-invalid @enderror" id="email" name="email" type="email" required="" placeholder="Inserisci" wire:model="email" />
+                                            @error('email')
+                                                <div class="invalid-feedback">{{ $message }}</div>
+                                            @enderror
                                         </div>
                                     </div>
                                     <div class="col-md-12 mb-3">
                                         <div class="form-group">
                                             <label for="password">Password</label>
                                             <div class="form-input position-relative">
-                                                <input class="form-control input-white" id="password" name="password" type="password" required="" placeholder="Inserisci" />
+                                                <input class="form-control input-white @error('password') is-invalid @enderror" id="password" name="password" type="password" required="" placeholder="Inserisci" wire:model="password" />
+                                                @error('password')
+                                                    <div class="invalid-feedback">{{ $message }}</div>
+                                                @enderror
                                                 <div class="show-hide"><span class="show text-white"> </span></div>
                                             </div>
                                             <a class="link text-secondary d-inline-block mt-2 f-w-300" href="/forget-password">Hai dimenticato la password?</a>
@@ -31,7 +37,7 @@
                                 </div>
                                 <div class="form-group mb-0 checkbox-checked">
                                     <div class="text-center mt-4">
-                                        <button class="btn btn-secondary btn-block text-uppercase fw-bold btn-large" type="submit">Accedi</button>
+                                        <button class="btn btn-secondary btn-block text-uppercase fw-bold btn-large" type="button" wire:click="login()">Accedi</button>
                                     </div>
                                 </div>
                                 <div class="text-center mt-3">

+ 13 - 2
routes/web.php

@@ -1,11 +1,22 @@
 <?php
 
 use Illuminate\Support\Facades\Route;
+use App\Http\Middleware\TenantMiddleware;
 
 Route::get('/', \App\Livewire\Index::class);
 Route::get('/login', \App\Livewire\Login::class);
 Route::get('/registration', \App\Livewire\Registration::class);
-
 Route::get('/onboarding', \App\Livewire\Onboarding::class);
 
-Route::get('/dashboard', \App\Livewire\Dashboard::class);
+//Route::group(['middleware' => 'auth'], function () {
+Route::middleware([TenantMiddleware::class])->group(function () {
+
+    Route::group(['prefix'=>'admin'],function (){
+
+        Route::get('/dashboard', \App\Livewire\Dashboard::class)->name('dashboard');
+        Route::get('/company', \App\Livewire\Company::class)->name('company');
+        //Route::get('/company_service', \App\Livewire\CompanyService::class)->name('company_service');
+
+    });
+
+});