Proculair B.V.
Proculair B.V.
FFilament
Created by Proculair B.V. on 11/4/2024 in #❓┊help
Unable to access pivot data on resource when using Multi-tenancy
Hi, I've added a pivot column is_active to the relation between users and tenants. But it's value seems inaccessible on the UserResource
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Tenant extends Model
{
// ...

public function users(): BelongsToMany
{
return $this->belongsToMany(User::class, 'tenant_users')
->withPivot([
'is_active',
]);
}
}
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Tenant extends Model
{
// ...

public function users(): BelongsToMany
{
return $this->belongsToMany(User::class, 'tenant_users')
->withPivot([
'is_active',
]);
}
}
<?php

namespace App\Models;

use Filament\Models\Contracts\HasDefaultTenant;
use Filament\Models\Contracts\HasTenants;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements HasDefaultTenant, HasTenants
{
// ...

public function tenants(): BelongsToMany
{
return $this->belongsToMany(Tenant::class, 'tenant_users')
->withPivot([
'is_active',
]);
}
}
<?php

namespace App\Models;

use Filament\Models\Contracts\HasDefaultTenant;
use Filament\Models\Contracts\HasTenants;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements HasDefaultTenant, HasTenants
{
// ...

public function tenants(): BelongsToMany
{
return $this->belongsToMany(Tenant::class, 'tenant_users')
->withPivot([
'is_active',
]);
}
}
<?php

namespace App\Filament\AppPanel\Resources;

use App\Models\User;
use Filament\Resources\Resource;
use Filament\Tables\Table;

class UserResource extends Resource
{
protected static ?string $model = User::class;

protected static ?string $tenantOwnershipRelationshipName = 'tenants';

// ...

public static function table(Table $table): Table
{
return $table
->columns([
IconColumn::make('is_active')
->boolean()
]);
}
}
<?php

namespace App\Filament\AppPanel\Resources;

use App\Models\User;
use Filament\Resources\Resource;
use Filament\Tables\Table;

class UserResource extends Resource
{
protected static ?string $model = User::class;

protected static ?string $tenantOwnershipRelationshipName = 'tenants';

// ...

public static function table(Table $table): Table
{
return $table
->columns([
IconColumn::make('is_active')
->boolean()
]);
}
}
1 replies
FFilament
Created by Proculair B.V. on 10/17/2024 in #❓┊help
Programmatically open relationManager View/Edit modal
Goal I have linked two relationManagers to a Resource (parent). On the parent I would like to be able to call a function which opens the View/Edit action on a specific record in the relationManager. Motivation It would be great to "deeplink" to a record in a resource. What I mean by this is that I would like to be able to craft links like "/app/example/12#books-34". This link would open the example resource (id 12) and trigger the View/Edit on the book (id 34) record in the BooksRelationManager. Question Is this possible? How could I do this?
14 replies
FFilament
Created by Proculair B.V. on 10/4/2024 in #❓┊help
Enable Flare JS error logging
I would like to integrate Flares client side JS error logging (https://flareapp.io/docs/integration/javascript-error-tracking/installation). The problem is that I cannot link to Vite assets in Filament because that will create a circular dependency.
FilamentAsset::register([
Js::make('app-js', Vite::asset('resources/js/app.js')),
]);
FilamentAsset::register([
Js::make('app-js', Vite::asset('resources/js/app.js')),
]);
import { flare } from "@flareapp/js";

const env = process.env.NODE_ENV;
if (env === "production" || env === "staging") {
flare.light();
}
import { flare } from "@flareapp/js";

const env = process.env.NODE_ENV;
if (env === "production" || env === "staging") {
flare.light();
}
When doing this Vite will require a manifest which can only be generated after composer is installed which can only happen after the manifest is generated... etc. How should I solve this?
4 replies
FFilament
Created by Proculair B.V. on 9/28/2024 in #❓┊help
Align BulkActions
No description
3 replies
FFilament
Created by Proculair B.V. on 9/7/2024 in #❓┊help
Version 3.2.97 breaks copying form fields when viewing them
Please see the video. Between version 3.2.96 and 3.2.97 something changed causing the Markdowneditor field to not be copiable when viewing the resource in a relation manager. https://github.com/filamentphp/filament/compare/v3.2.96...v3.2.97
18 replies
FFilament
Created by Proculair B.V. on 7/16/2024 in #❓┊help
Authorization in RelationManager not allowing to use different model
Hi, I have a UserResource with a TokenRelationManager. The tokens use model Laravel\Sanctum\PersonalAccessToken. I have the following header action on the relation manager:
->headerActions([
Tables\Actions\CreateAction::make()
->label('Token Aanmaken')
->authorize('createToken', User::class)
->using(function (array $data, string $model): PersonalAccessToken {
/** @var User */
$user = $this->getOwnerRecord();

$token = $user->createToken(
name: $data['name'],
abilities: $data['abilities'],
expiresAt: $data['expires_at']
);

Session::flash('token', $token->plainTextToken);

return $token->accessToken;
})
->successNotification(function (): Notification {
$token = Session::pull('token');
[$id, $token] = explode('|', $token, 2);

$this->js("window.navigator.clipboard.writeText('{$token}')");

return Notification::make()
->title('Token Aangemaakt!')
->body($token)
->persistent()
->success()
->color('success')
->icon('heroicon-o-key');
}),
])
->headerActions([
Tables\Actions\CreateAction::make()
->label('Token Aanmaken')
->authorize('createToken', User::class)
->using(function (array $data, string $model): PersonalAccessToken {
/** @var User */
$user = $this->getOwnerRecord();

$token = $user->createToken(
name: $data['name'],
abilities: $data['abilities'],
expiresAt: $data['expires_at']
);

Session::flash('token', $token->plainTextToken);

return $token->accessToken;
})
->successNotification(function (): Notification {
$token = Session::pull('token');
[$id, $token] = explode('|', $token, 2);

$this->js("window.navigator.clipboard.writeText('{$token}')");

return Notification::make()
->title('Token Aangemaakt!')
->body($token)
->persistent()
->success()
->color('success')
->icon('heroicon-o-key');
}),
])
As you can see in ->authorize('createToken', User::class) I want to trigget the createToken method on the UserPolicy. Because of this code in the InteractsWithRecord trait the model of the relation manager gets prepended as an argument:
protected function parseAuthorizationArguments(array $arguments): array
{
if ($record = $this->getRecord()) {
array_unshift($arguments, $record);
} elseif ($model = $this->getModel()) {
array_unshift($arguments, $model);
}

return $arguments;
}
protected function parseAuthorizationArguments(array $arguments): array
{
if ($record = $this->getRecord()) {
array_unshift($arguments, $record);
} elseif ($model = $this->getModel()) {
array_unshift($arguments, $model);
}

return $arguments;
}
How could I trigger the authorization method to use the UserPolicy?
3 replies
FFilament
Created by Proculair B.V. on 1/4/2024 in #❓┊help
Split action footer alignment, delete btn start & submit btn end
No description
6 replies
FFilament
Created by Proculair B.V. on 1/3/2024 in #❓┊help
ManyToMany Repeater: Call to a member function subscriptionProducts() on null
I have followed this guide: https://filamentphp.com/docs/3.x/forms/fields/repeater#integrating-with-a-belongstomany-eloquent-relationship but unfortunately no luck. My models: subscription: - id - name productSubscription - id - product_id - subscription_id - price - quantity product: - id - name - tax - default_price
9 replies
FFilament
Created by Proculair B.V. on 12/11/2023 in #❓┊help
Hide disabledOption in Select
When disabling an option in Select I would like to not display that option. How is this possible?
Select::make(static::$name)
->label(static::$label)
->relationship(static::$name, static::$attribute)
->preload()
->multiple()
->disableOptionWhen(function (string $value, ManageCustomerUsers $livewire): bool {
return $livewire->getOwnerRecord()->id === $value;
});
Select::make(static::$name)
->label(static::$label)
->relationship(static::$name, static::$attribute)
->preload()
->multiple()
->disableOptionWhen(function (string $value, ManageCustomerUsers $livewire): bool {
return $livewire->getOwnerRecord()->id === $value;
});
14 replies
FFilament
Created by Proculair B.V. on 12/2/2023 in #❓┊help
Trigger RelationManager `EditAction` from Infolist Section `headerActions`
No description
7 replies
FFilament
Created by Proculair B.V. on 11/30/2023 in #❓┊help
Alert when navigation away from dirty form
No description
4 replies
FFilament
Created by Proculair B.V. on 11/24/2023 in #❓┊help
Tenancy: access tenant in `canAccessPanel` function
No description
7 replies
FFilament
Created by Proculair B.V. on 11/23/2023 in #❓┊help
Tenancy: resource of models belonging to multiple tenants
Hi, In a multi-tenancy setup a user can belong to multiple tenants. Each tenant must be able to edit users belonging to that tenant. How do I scope this in the UserResouce?
7 replies
FFilament
Created by Proculair B.V. on 11/15/2023 in #❓┊help
Access tableFilters in resource
Hi, On a tableWidget you can access tableFilters like so: ->visible(fn () => ZaakState::ACTIVE->value === $this->tableFilters['state']['value']) Can you also access these in a a Resource?
3 replies
FFilament
Created by Proculair B.V. on 11/9/2023 in #❓┊help
How to type in the datepicker input box?
For ease of use I would like to be able to type into the datepicker input box instead of having to use the datepicker. This can be sort of achieved with the following code:
TextInput::make($name)
->mask('99/99/9999')
->placeholder(__('23/06/1912'))
->dehydrateStateUsing(
fn (string $state): ?Carbon => $state
? Carbon::createFromFormat(static::$format, $state)
: null
);
TextInput::make($name)
->mask('99/99/9999')
->placeholder(__('23/06/1912'))
->dehydrateStateUsing(
fn (string $state): ?Carbon => $state
? Carbon::createFromFormat(static::$format, $state)
: null
);
The downside of this approach is that you lose access to the minDate() and maxDate() methods. Is there a way to have the best of both worlds?
5 replies
FFilament
Created by Proculair B.V. on 10/23/2023 in #❓┊help
Composer install fails because of required Vite files
13 replies
FFilament
Created by Proculair B.V. on 10/16/2023 in #❓┊help
Add widgets to an infolist?
Is it possible to place widgets inside an infolist?
7 replies
FFilament
Created by Proculair B.V. on 10/3/2023 in #❓┊help
Modal::closedByClickingAway(false) but allow notifications centre to be closed by clicking away.
Hi, I've set Modal::closedByClickingAway(false); in my service provider. However, I would still like the notification centre to be closable by clicking away. How would I achieve this?
2 replies
FFilament
Created by Proculair B.V. on 9/27/2023 in #❓┊help
How to align modal buttons similar to alignFormActionsEnd()
use Filament\Pages\Page;
use Filament\Support\View\Components\Modal;

Page::alignFormActionsEnd();

Modal::closeButton(false);
Modal::closedByClickingAway(false);
// Modal::alignFormActionsEnd(); Does this exist?
use Filament\Pages\Page;
use Filament\Support\View\Components\Modal;

Page::alignFormActionsEnd();

Modal::closeButton(false);
Modal::closedByClickingAway(false);
// Modal::alignFormActionsEnd(); Does this exist?
6 replies
FFilament
Created by Proculair B.V. on 9/25/2023 in #❓┊help
How to disable RequestPasswordReset but allow ResetPassword?
I would like to use the built-in ResetPassword class of Filament. However, I do not want my users to be able to request a password reset themselves. They should contact their admin for that, he can then generate a password request which gets sent to the user. How would I achieve this in Filament? I tried something like this: ->passwordReset(requestAction: null, resetAction: ResetPassword::class)
7 replies