Donnell Wyche
Donnell Wyche
FFilament
Created by Donnell Wyche on 10/16/2024 in #❓┊help
Help with Global Search in Filament Relation Manager without a Resource
What I am trying to do:
I have a ProfileResource that contains a PcoFormSubmissionsRelationManager, there is no standalone Filament Resource for PcoFormSubmissionsResource. I want to enable the global search feature in FilamentPHP to search and retrieve the values of these form submissions by way of the submissionValues field. What I did:
- If the PcoFormSubmission had its own Filament Resource, I would typically use protected static ?string $recordTitleAttribute = 'submissionValues'; to make it searchable. - However, since this is a Relation Manager (and not a separate Resource), I am unsure how to achieve the same result. My issue/the error:
The global search does not seem to work for this Relation Manager setup. Has anyone successfully implemented global search for just a Relation Manager (without a Resource), or is there a way to search the submissions? Any advice or examples would be helpful. The table search is working fine, it's just the global search I'm struggling with. Code snippets from my setup: PcoFormSubmissionsRelationManager:
<?php

namespace App\Filament\Resources\ProfileResource\RelationManagers;

use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use App\Models\PcoFormSubmission;

class PcoFormSubmissionsRelationManager extends RelationManager
{
protected static ?string $relationship = 'formSubmissions';
protected static ?string $recordTitleAttribute = 'submissionValues';

public function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('submissionValues'),
])
->filters([/* Filters here */]);
}
}
<?php

namespace App\Filament\Resources\ProfileResource\RelationManagers;

use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use App\Models\PcoFormSubmission;

class PcoFormSubmissionsRelationManager extends RelationManager
{
protected static ?string $relationship = 'formSubmissions';
protected static ?string $recordTitleAttribute = 'submissionValues';

public function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('submissionValues'),
])
->filters([/* Filters here */]);
}
}
Thanks in advance for any insights!
5 replies
FFilament
Created by Donnell Wyche on 11/29/2023 in #❓┊help
ImportAction Infinite Loop when using the new FilamentPHP 3.1 Import Action
Created an Importer, ran it, then got a flood of failed jobs because of this error in the vendor/filament/actions/src/Imports/Models/Import.php file on line 43: Cannot use "::class" on value of type null array:1 [▶ "exception" => TypeError {#4305▶ #message: "Cannot use "::class" on value of type null" #code: 0 #file: "vendor/filament/actions/src/Imports/Models/Import.php" #line: 43 } ] I'm using Laravel 10.34.2, PHP 8.2.12, Filament 3.1 with Multi-tenancy. As best I can tell, this function isn't resolving the User model as the Authenticatable class. --- My User model is class User extends Authenticatable implements FilamentUser, HasAvatar, HasTenants
26 replies
FFilament
Created by Donnell Wyche on 10/30/2023 in #❓┊help
Integrating Multi-Tenancy with Laravel Spark: Handling Subscriptions and Trial Periods
What I am trying to do: I am integrating FilamentPHP's multi-tenancy features with Laravel Spark. I want to ensure that the application correctly handles trial periods as configured in Laravel Spark. This solution works. What I did: I implemented a custom middleware named CheckTenantSubscription to check whether a tenant has an active subscription or is within their trial period, redirecting them to the billing page if neither condition is met. In this middleware, I used Filament::getTenant() to retrieve the tenant's information, and then proceeded to check their subscription status and trial period against the current date and time. My issue/the error: Using FilamentPHP's ->requiresTenantSubscription() seems to ignore Laravel Spark’s trial period. I expected it to consider the trial period automatically during subscription checks. In my middleware, I’ve explicitly handled trial and subscription checks. However, I’m uncertain if this aligns with FilamentPHP standards, especially when integrated with Laravel Spark. I am looking for guidance on whether there is a standard or more "Filament" way to handle this scenario. Code:
public function handle(Request $request, Closure $next): Response
{
$tenant = Filament::getTenant();

if (!$tenant) {
return $next($request);
}

// Check if the tenant is within their trial period
if ($tenant->trial_ends_at && Carbon::now()->lessThan($tenant->trial_ends_at)) {
return $next($request);
}

// Check for active subscription
if (!$tenant->subscribed()) {
return redirect()->route('spark.portal', ['type' => 'team', 'id' => $tenant->id]);
}

return $next($request);
}
public function handle(Request $request, Closure $next): Response
{
$tenant = Filament::getTenant();

if (!$tenant) {
return $next($request);
}

// Check if the tenant is within their trial period
if ($tenant->trial_ends_at && Carbon::now()->lessThan($tenant->trial_ends_at)) {
return $next($request);
}

// Check for active subscription
if (!$tenant->subscribed()) {
return redirect()->route('spark.portal', ['type' => 'team', 'id' => $tenant->id]);
}

return $next($request);
}
4 replies