Created
October 3, 2023 21:46
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$table->foreignId('tenant_id')->nullable()->constrained(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$table->uuid('code'); | |
$table->string('name'); | |
$table->string('slug'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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