Nate
Nate
FFilament
Created by Daniel Plomp on 12/1/2023 in #❓┊help
Update TextInput based on Select value
Does typecasting it help since then it will know what to inject?
use Filament\Forms\Get;

->hidden(fn(Get $get) => $get('job_salary_type') === 0),
use Filament\Forms\Get;

->hidden(fn(Get $get) => $get('job_salary_type') === 0),
4 replies
FFilament
Created by Nate on 11/27/2023 in #❓┊help
Is there a way to intercept the activeTab parameter in the resource table function?
shipit
14 replies
FFilament
Created by Nate on 11/27/2023 in #❓┊help
Is there a way to intercept the activeTab parameter in the resource table function?
Ok I have found a "hacky" way around this. I overrode the vendor/filament/components/tabs/item.blade.php so I could add a click event (there is already a wire:click on there but it just sets and not dispatched).
@click="$dispatch('tabChange', { tab: '{{ $slot->toHtml() }}' })"
@click="$dispatch('tabChange', { tab: '{{ $slot->toHtml() }}' })"
I then listen for the event in the list page like so:
#[On('tabChange')]
public function tabChange(): void
{
$this->resetTable();
}
#[On('tabChange')]
public function tabChange(): void
{
$this->resetTable();
}
This refreshed the table again so you can get the current tab value (without it you can only get the previous tab value as the page doesn't refresh between tab changes). I now have access to the current active tab and can then switch tables based on this.
public function table(Table $table): Table
{
if ($table->getLivewire()->activeTab === 'Dispatch certificates') {
return $this->batchedTable($table);
}

return $this->defaultTable($table);
}
public function table(Table $table): Table
{
if ($table->getLivewire()->activeTab === 'Dispatch certificates') {
return $this->batchedTable($table);
}

return $this->defaultTable($table);
}
14 replies
FFilament
Created by Nate on 11/27/2023 in #❓┊help
Is there a way to intercept the activeTab parameter in the resource table function?
@Ola A @Leandro Ferreira Yeah the problem is this doesn't change the underlying query. Be better if we can pull in a different table.
14 replies
FFilament
Created by Nate on 11/27/2023 in #❓┊help
Is there a way to intercept the activeTab parameter in the resource table function?
It may be enough wish you could do $table->hidden(). Let me see if the above is enough. Thanks.
14 replies
FFilament
Created by Nate on 11/10/2023 in #❓┊help
Tab change event
Thank you @Dennis Koch this was the solution we were looking for.
BulkAction::make('Print Mailout')
->label('Print Mailout PDFs')
->visible(fn ($livewire) => $livewire->activeTab == 'whatever')
BulkAction::make('Print Mailout')
->label('Print Mailout PDFs')
->visible(fn ($livewire) => $livewire->activeTab == 'whatever')
8 replies
FFilament
Created by code jam on 7/31/2023 in #❓┊help
multi tenancy with Filament V3 & stancl/tenancy package?
No description
10 replies
FFilament
Created by code jam on 7/31/2023 in #❓┊help
multi tenancy with Filament V3 & stancl/tenancy package?
10 replies
FFilament
Created by code jam on 7/31/2023 in #❓┊help
multi tenancy with Filament V3 & stancl/tenancy package?
10 replies
FFilament
Created by Shaung Bhone on 5/29/2023 in #❓┊help
Third party icons
FYI if you use v2 you can use custom SVG's such as font-awesome. Haven't figure that out on v3 yet.
10 replies
FFilament
Created by Nate on 7/13/2023 in #❓┊help
Switching Database Connection on a Resource
Found a way! Rgistered my new middleware:
// config/filament.php

'middleware' => [
'auth' => [
Authenticate::class,
],
'base' => [
InitializeTenancyBySubdomain:class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DispatchServingFilamentEvent::class,
MirrorConfigToSubpackages::class,
],
],
// config/filament.php

'middleware' => [
'auth' => [
Authenticate::class,
],
'base' => [
InitializeTenancyBySubdomain:class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DispatchServingFilamentEvent::class,
MirrorConfigToSubpackages::class,
],
],
//App\Http\InitializeTenancyBySubdomain

<?php

declare(strict_types=1);

namespace App\Http\Middleware;

use App\Context\Tenant\Models\Tenant;
use Illuminate\Http\Request;
use Stancl\Tenancy\Middleware\InitializeTenancyBySubdomain as BaseMiddleware;
use Closure;

class InitializeTenancyBySubdomain extends BaseMiddleware
{
public function handle(Request $request, Closure $next): mixed
{
$route = $request->route();
$record = $route->parameter('record');

if ($route->uri() === 'admin/tenancy/tenants/{record}' && $tenant = Tenant::find($record)) {
$subdomain = $tenant->domain->domain;
$request->headers->set('host', $subdomain . '.' . $request->getHost());
}

// Passes back to the tenancyforlaravel tenancy initialisation middleware.
return parent::handle(request: $request, next: $next);
}
}
//App\Http\InitializeTenancyBySubdomain

<?php

declare(strict_types=1);

namespace App\Http\Middleware;

use App\Context\Tenant\Models\Tenant;
use Illuminate\Http\Request;
use Stancl\Tenancy\Middleware\InitializeTenancyBySubdomain as BaseMiddleware;
use Closure;

class InitializeTenancyBySubdomain extends BaseMiddleware
{
public function handle(Request $request, Closure $next): mixed
{
$route = $request->route();
$record = $route->parameter('record');

if ($route->uri() === 'admin/tenancy/tenants/{record}' && $tenant = Tenant::find($record)) {
$subdomain = $tenant->domain->domain;
$request->headers->set('host', $subdomain . '.' . $request->getHost());
}

// Passes back to the tenancyforlaravel tenancy initialisation middleware.
return parent::handle(request: $request, next: $next);
}
}
3 replies
FFilament
Created by Nate on 7/13/2023 in #❓┊help
Switching Database Connection on a Resource
Hmm maybe adding a custom middleware in the config.
'middleware' => [
'auth' => [
Authenticate::class,
],
'base' => [
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DispatchServingFilamentEvent::class,
MirrorConfigToSubpackages::class,
],
],
'middleware' => [
'auth' => [
Authenticate::class,
],
'base' => [
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DispatchServingFilamentEvent::class,
MirrorConfigToSubpackages::class,
],
],
3 replies
FFilament
Created by Chrysippus on 7/7/2023 in #❓┊help
table for custom page
It's because we use both livewire and react depending which page you are on
51 replies
FFilament
Created by Chrysippus on 7/7/2023 in #❓┊help
table for custom page
Remove this line import react from '@vitejs/plugin-react';
51 replies
FFilament
Created by Chrysippus on 7/7/2023 in #❓┊help
table for custom page
I've updated it now
51 replies
FFilament
Created by Chrysippus on 7/7/2023 in #❓┊help
table for custom page
@chrysippus2497 Sorry about that I left some stray code in the vite config
51 replies
FFilament
Created by Chrysippus on 7/7/2023 in #❓┊help
table for custom page
That is using the latest Vite
51 replies
FFilament
Created by Chrysippus on 7/7/2023 in #❓┊help
table for custom page
No but that's our productions setup and we have both Filament admin and custom pages with tables for our client app 🙂
51 replies
FFilament
Created by Chrysippus on 7/7/2023 in #❓┊help
table for custom page
Mix file? You're installing Vite though? Try this setup. In your app.blade.php instead of asset() you use the following:
@vite(['resources/css/app.css', 'resources/js/app.js'])
@vite(['resources/css/app.css', 'resources/js/app.js'])
// Vite config file
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/filament.css',
'resources/css/app.css',
'resources/js/app.js',
// other custom scripts...
],
refresh: true
}),
],
resolve: {
alias: {
'@': '/resources/js',
}
}
});
// Vite config file
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/filament.css',
'resources/css/app.css',
'resources/js/app.js',
// other custom scripts...
],
refresh: true
}),
],
resolve: {
alias: {
'@': '/resources/js',
}
}
});
// Filament service provider
class FilamentServiceProvider extends ServiceProvider
{
public function boot(): void
{
Filament::serving(static function () {
Filament::registerViteTheme('resources/css/filament.css');
});
}

// Other stuff ...
}
// Filament service provider
class FilamentServiceProvider extends ServiceProvider
{
public function boot(): void
{
Filament::serving(static function () {
Filament::registerViteTheme('resources/css/filament.css');
});
}

// Other stuff ...
}
/* resources/css/filament.css */
@import '../../vendor/filament/filament/resources/css/app.css';

/* Somme overrides for your Filament theme. */
header.filament-main-topbar {
background-color: hotpink;
}
/* resources/css/filament.css */
@import '../../vendor/filament/filament/resources/css/app.css';

/* Somme overrides for your Filament theme. */
header.filament-main-topbar {
background-color: hotpink;
}
// package.json
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"@tailwindcss/forms": "^0.4.0",
"@tailwindcss/typography": "^0.5.3",
"alpinejs": "^3.4.2",
"autoprefixer": "10.4.5",
"laravel-vite-plugin": "^0.7.8",
"postcss": "^8.4.14",
"tailwindcss": "^3.0.24",
"tippy.js": "^6.3.7",
"vite": "^4.3.9"
// other dev deps
},
"dependencies": {
"@alpinejs/focus": "^3.10.2",
"@awcodes/alpine-floating-ui": "^3.5.0"
// rest of your deps
},
"overrides": {
"autoprefixer": "10.4.5"
}
}
// package.json
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"@tailwindcss/forms": "^0.4.0",
"@tailwindcss/typography": "^0.5.3",
"alpinejs": "^3.4.2",
"autoprefixer": "10.4.5",
"laravel-vite-plugin": "^0.7.8",
"postcss": "^8.4.14",
"tailwindcss": "^3.0.24",
"tippy.js": "^6.3.7",
"vite": "^4.3.9"
// other dev deps
},
"dependencies": {
"@alpinejs/focus": "^3.10.2",
"@awcodes/alpine-floating-ui": "^3.5.0"
// rest of your deps
},
"overrides": {
"autoprefixer": "10.4.5"
}
}
51 replies