Skip to content

Instantly share code, notes, and snippets.

@NandoKstroNet
Created October 3, 2023 21:46
Show Gist options
  • Save NandoKstroNet/63ea6c2e3be6fd618d661516ee136bdb to your computer and use it in GitHub Desktop.
Save NandoKstroNet/63ea6c2e3be6fd618d661516ee136bdb to your computer and use it in GitHub Desktop.
Alguns Recursos Importante para Configurar o Tenant no FilamentPHP V3 / https://codeexperts.com.br
$table->foreignId('tenant_id')->nullable()->constrained();
$table->uuid('code');
$table->string('name');
$table->string('slug');
<?php
namespace App\Filament\Pages\Tenancy;
use App\Models\Tenant;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\RegisterTenant as BaseRegisterTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class RegisterTenant extends BaseRegisterTenant
{
public static function getLabel(): string
{
return 'Registrar Seu Negócio';
}
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name'),
// ...
]);
}
protected function handleRegistration(array $data): Tenant
{
$data['code'] = Str::uuid();
$data['slug'] = Str::slug($data['name']);
$tenant = Tenant::create($data);
$tenant->members()->attach(auth()->user());
return $tenant;
}
}
$table->foreignId('tenant_id')->constrained();
$table->foreignId('user_id')->constrained();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment