Tieme
Tieme
FFilament
Created by Tieme on 4/18/2024 in #❓┊help
Relationmanager in Livewire Infolist component
Hi All, I'm trying to get a realtionmanager in a infolist livewire component.
Infolists\Components\Livewire::make(VaccinesRelationManager::class)
->key('vaccines-table')
->lazy(),
Infolists\Components\Livewire::make(VaccinesRelationManager::class)
->key('vaccines-table')
->lazy(),
When i do this i get following error.
Typed property Filament\Resources\RelationManagers\RelationManager::$ownerRecord must not be accessed before initialization
Typed property Filament\Resources\RelationManagers\RelationManager::$ownerRecord must not be accessed before initialization
Is there anyway to do this without defining it in the below function on the resource? The reason i don't want to have it in below function is that the Infolist has tabs lay-out and need the table in one of the tabs. I know i can make my own livewire component, but a relationmanager has all the functions that i need.
public static function getRelations(): array
{
return [
];
}
public static function getRelations(): array
{
return [
];
}
Thanks for you help.
9 replies
FFilament
Created by Tieme on 3/27/2024 in #❓┊help
Register Form with Relations
Hi All, I am making a custome register form just like the documents (https://filamentphp.com/docs/3.x/panels/users#customizing-the-authentication-features) Here is my complete code for the register form (https://gist.github.com/sitenzo/e30e85cabad4020097eed43c3ca51fad) I want to create a new user with relations on register, only the user is created without any relationship records. This is my user model
class User extends Authenticatable implements MustVerifyEmail
{
use HasFactory, HasRoles, Notifiable, SoftDeletes,TwoFactorAuthenticatable;

public function address(): hasOne
{
return $this->hasOne(Address::class);
}

public function phone()
{
return $this->hasMany(Phone::class);
}
}
class User extends Authenticatable implements MustVerifyEmail
{
use HasFactory, HasRoles, Notifiable, SoftDeletes,TwoFactorAuthenticatable;

public function address(): hasOne
{
return $this->hasOne(Address::class);
}

public function phone()
{
return $this->hasMany(Phone::class);
}
}
Does anyone know if this is possible and if so, what am i overlooking? Thanks for the support, if you need anymore information i can provide it.
6 replies
FFilament
Created by Tieme on 2/11/2024 in #❓┊help
Enum select with live() on Create and Edit form
Hi All, I have a question, i use a select with Enum and some dependecie fields/fieldset on this value.
Forms\Components\Select::make('row_type')
->label(Helpers::translate('Row Type'))
->options(RowType::class)
->default(RowType::NORMAL)
->live()
->required()
->native(false),
Forms\Components\Select::make('row_type')
->label(Helpers::translate('Row Type'))
->options(RowType::class)
->default(RowType::NORMAL)
->live()
->required()
->native(false),
The fieldset
Forms\Components\Fieldset::make(Helpers::translate('Product settings'))
->schema([])
->columns(12)
->visible(fn (Forms\Get $get): bool => $get('row_type') == RowType::NORMAL)
Forms\Components\Fieldset::make(Helpers::translate('Product settings'))
->schema([])
->columns(12)
->visible(fn (Forms\Get $get): bool => $get('row_type') == RowType::NORMAL)
On create record this works, on edit record this works not. That is because on create $get('row_type') is Enum and on Edit it is integer even tho i cast it in the model
protected $casts = [
'row_type' => RowType::class,
];
protected $casts = [
'row_type' => RowType::class,
];
For now i have create a helper to get this to work.
public static function GetValueFromEnum(mixed $enum)
{
if (is_numeric($enum)) {
return $enum;
}

return $enum->value;
}
public static function GetValueFromEnum(mixed $enum)
{
if (is_numeric($enum)) {
return $enum;
}

return $enum->value;
}
This is how i use it now
->visible(fn (Forms\Get $get): bool => Helpers::GetValueFromEnum($get('row_type')) == RowType::NORMAL->value)
->visible(fn (Forms\Get $get): bool => Helpers::GetValueFromEnum($get('row_type')) == RowType::NORMAL->value)
It works, but i think there is a better and simpler solution only dont know how. Can anyone point me in the right direction? Thanks
3 replies
FFilament
Created by Tieme on 1/5/2024 in #❓┊help
Livewire form as widget
Hello Everyone, I'm currently using the Filament Spatie Settings plugin (https://filamentphp.com/plugins/filament-spatie-settings) and have created a Livewire form based on the guidelines found here: https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component. This was necessary as there wasn't a ready-made Form widget available for this purpose. My goal now is to integrate this Livewire form into a new page that will also include several table widgets. The idea is to have a single page that aggregates all data from one API source. Could anyone guide me on how to embed a Livewire form into a page as a widget? Is such integration feasible? Thank you for your assistance
2 replies
FFilament
Created by Tieme on 12/31/2023 in #❓┊help
Error on creating resource with custom --model-namespace
Hi All, I want to create a resource with following command php artisan make:filament-resource Customer --generate --soft-deletes --view --model-namespace=App\\Models\\Team as documented here https://filamentphp.com/docs/3.x/panels/resources/getting-started#specifiying-a-custom-model-namespace This throws me a Fatal error :
PHP Fatal error: Cannot declare class App\Models\Team\Customer, because the name is already in use in C:\Users\***\PHPStormProjects\***\app\Models\Team\Customer.php on line 14

Symfony\Component\ErrorHandler\Error\FatalError

Cannot declare class App\Models\Team\Customer, because the name is already in use

at app\Models\Team\Customer.php:14
10▕ use Illuminate\Database\Eloquent\Model;
11▕ use Illuminate\Database\Eloquent\Relations\BelongsTo;
12▕ use Illuminate\Database\Eloquent\SoftDeletes;
13▕
➜ 14▕ class Customer extends Model
15▕ {
16▕ use BelongsToTeam;
17▕ use HasFactory;
18▕ use HasUserStamps;


Whoops\Exception\ErrorException

Cannot declare class App\Models\Team\Customer, because the name is already in use

at app\Models\Team\Customer.php:14
10▕ use Illuminate\Database\Eloquent\Model;
11▕ use Illuminate\Database\Eloquent\Relations\BelongsTo;
12▕ use Illuminate\Database\Eloquent\SoftDeletes;
13▕
➜ 14▕ class Customer extends Model
15▕ {
16▕ use BelongsToTeam;
17▕ use HasFactory;
18▕ use HasUserStamps;

1 vendor\filp\whoops\src\Whoops\Run.php:514
Whoops\Run::handleError("Cannot declare class App\Models\Team\Customer, because the name is already in use", "C:\Users\***\PHPStormProjects\***\app\Models\Team\Customer.php")

2 [internal]:0
Whoops\Run::handleShutdown()
PHP Fatal error: Cannot declare class App\Models\Team\Customer, because the name is already in use in C:\Users\***\PHPStormProjects\***\app\Models\Team\Customer.php on line 14

Symfony\Component\ErrorHandler\Error\FatalError

Cannot declare class App\Models\Team\Customer, because the name is already in use

at app\Models\Team\Customer.php:14
10▕ use Illuminate\Database\Eloquent\Model;
11▕ use Illuminate\Database\Eloquent\Relations\BelongsTo;
12▕ use Illuminate\Database\Eloquent\SoftDeletes;
13▕
➜ 14▕ class Customer extends Model
15▕ {
16▕ use BelongsToTeam;
17▕ use HasFactory;
18▕ use HasUserStamps;


Whoops\Exception\ErrorException

Cannot declare class App\Models\Team\Customer, because the name is already in use

at app\Models\Team\Customer.php:14
10▕ use Illuminate\Database\Eloquent\Model;
11▕ use Illuminate\Database\Eloquent\Relations\BelongsTo;
12▕ use Illuminate\Database\Eloquent\SoftDeletes;
13▕
➜ 14▕ class Customer extends Model
15▕ {
16▕ use BelongsToTeam;
17▕ use HasFactory;
18▕ use HasUserStamps;

1 vendor\filp\whoops\src\Whoops\Run.php:514
Whoops\Run::handleError("Cannot declare class App\Models\Team\Customer, because the name is already in use", "C:\Users\***\PHPStormProjects\***\app\Models\Team\Customer.php")

2 [internal]:0
Whoops\Run::handleShutdown()
How can i handle custom model namespace ? i already have tried --model-namespace=App\\Models\\Team\\Customer this wil create the resource, only not generate all the fields for me and also namespace is wrong.
4 replies
FFilament
Created by Tieme on 12/22/2023 in #❓┊help
static values Table / Infolist/ DateTimePicker based on locale
Hi All, There are some static values in the Table / Infolist/ DateTimePicker class. If i set them in AppServiceProvider the values change with my options. Example settings
Infolists\Infolist::$defaultCurrency = $options['defaultCurrency'];
Infolists\Infolist::$defaultDateDisplayFormat = $options['defaultDateDisplayFormat'];
Infolists\Infolist::$defaultDateTimeDisplayFormat = $options['defaultDateTimeDisplayFormat'];
Infolists\Infolist::$defaultTimeDisplayFormat = $options['defaultTimeDisplayFormat'];
Infolists\Infolist::$defaultCurrency = $options['defaultCurrency'];
Infolists\Infolist::$defaultDateDisplayFormat = $options['defaultDateDisplayFormat'];
Infolists\Infolist::$defaultDateTimeDisplayFormat = $options['defaultDateTimeDisplayFormat'];
Infolists\Infolist::$defaultTimeDisplayFormat = $options['defaultTimeDisplayFormat'];
I want to change these values based on current locale from user. I use this plugin to add local to dashboard. https://filamentphp.com/plugins/bezhansalleh-language-switch I created a Middleware to set these settings. In the Middleware i have the correct locale. Now the problem is that these values are not set, and only the default in the classes are set. This is my complete Middleware : https://gist.github.com/sitenzo/4b357ab20284e1bf79bd3e5eef994036 How can i set these values based on locale? Thanks
7 replies
FFilament
Created by Tieme on 12/18/2023 in #❓┊help
Better way to manage default formats?
Hi All, I use filament with different locals. Some default dateformats are defined in following classes
Filament\Infolists\Infolist
Filament\Forms\Components\DateTimePicker
Filament\Tables\Table
Filament\Infolists\Infolist
Filament\Forms\Components\DateTimePicker
Filament\Tables\Table
At this moment i'm changing the formats of these configurations in AppServiceProvider (Code below) Now i want to know if there is a better way to manage these settings, this because when filament updates some additional $defaults can be added that are not in my AppServiceProvider Url to code : https://gist.github.com/sitenzo/a29807e72d38310a5a04f18e3d99f0dd
6 replies
FFilament
Created by Tieme on 12/17/2023 in #❓┊help
EditTenantProfile in Navigation
Hi All, I have Multi-tenancy and i can change my tenant information from the tenant menu
php
->tenantProfile(EditCompanyProfile::class)
php
->tenantProfile(EditCompanyProfile::class)
Now i want to change the location of this menu item to the Sidebar Navigation (below my Dashboard page) When i add
protected static bool $isDiscovered = true;
protected static bool $isDiscovered = true;
I get following error
Route [filament.company.tenant.profile] not defined.
Route [filament.company.tenant.profile] not defined.
I also get this error is i add it in panel like
->navigationItems([
NavigationItem::make()
->label('Test')
->url(EditCompanyProfile::getUrl([
'tenant' => Filament::getTenant()
]))
])
->navigationItems([
NavigationItem::make()
->label('Test')
->url(EditCompanyProfile::getUrl([
'tenant' => Filament::getTenant()
]))
])
Is it possible to change the location of the Tenant edit profile. Below is my complete page code for
EditCompanyProfile.php
EditCompanyProfile.php
<?php

namespace App\Filament\Company\Pages;

use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\EditTenantProfile;

class EditCompanyProfile extends EditTenantProfile
{
protected static bool $isDiscovered = true;
public static function getLabel(): string
{
return 'Company profile';
}

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make(__('filament/tenacy/company.contact_details'))
->columns(2)
->schema([
Forms\Components\TextInput::make('company_name')
->label(__('filament/tenacy/company.company_name'))
->required()
->maxLength(255),
]),
]);
}
}
<?php

namespace App\Filament\Company\Pages;

use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\EditTenantProfile;

class EditCompanyProfile extends EditTenantProfile
{
protected static bool $isDiscovered = true;
public static function getLabel(): string
{
return 'Company profile';
}

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make(__('filament/tenacy/company.contact_details'))
->columns(2)
->schema([
Forms\Components\TextInput::make('company_name')
->label(__('filament/tenacy/company.company_name'))
->required()
->maxLength(255),
]),
]);
}
}
Thanks for the help
4 replies
FFilament
Created by Tieme on 12/15/2023 in #❓┊help
Minimal Theme install?
Hi, I just preorderd the Minimal Theme. When i want to install after i added to composer.json
"repositories": [
{
"type": "composer",
"url": "https://privato.pub/composer/filament"
}
]
"repositories": [
{
"type": "composer",
"url": "https://privato.pub/composer/filament"
}
]
and executed the following command
composer require filament/minimal-theme:"^3.0@alpha"
composer require filament/minimal-theme:"^3.0@alpha"
i get following error
- Root composer.json requires filament/minimal-theme 3.0@alpha, found filament/minimal-theme[v3.0.0-alpha1, ..., v3.0.0-alpha12] but it does not match the constraint.
- Root composer.json requires filament/minimal-theme 3.0@alpha, found filament/minimal-theme[v3.0.0-alpha1, ..., v3.0.0-alpha12] but it does not match the constraint.
How can i solve this problem? Is it also possible to get Github Repo acces? Thanks
26 replies
FFilament
Created by Tieme on 12/9/2023 in #❓┊help
Table groups change default sort
I have a table with groups, the groups is a date group. I want to hide the settings because it is only one group, that works. Now i want to change the default sort of the group from asc to desc The defaultSort on the table does not work, how can i set this on the group? Below is my table,
return $table
->columns([

])
->emptyStateActions([
Tables\Actions\CreateAction::make(),
])
->defaultGroup('date')
->groups([
Tables\Grouping\Group::make('date')
->collapsible(true)
->date(true),
])
->groupingSettingsHidden()
->configure([
Table::$defaultDateDisplayFormat = 'l d F Y',
])
->defaultSort('date', 'desc');
return $table
->columns([

])
->emptyStateActions([
Tables\Actions\CreateAction::make(),
])
->defaultGroup('date')
->groups([
Tables\Grouping\Group::make('date')
->collapsible(true)
->date(true),
])
->groupingSettingsHidden()
->configure([
Table::$defaultDateDisplayFormat = 'l d F Y',
])
->defaultSort('date', 'desc');
i cant find any defaultSort on the Group::make
5 replies
FFilament
Created by Tieme on 11/26/2023 in #❓┊help
Table defaultGroup 'date' format datetime
Hi All, I'm grouping my records by date with
->defaultGroup('date')
->configure([
Table::$defaultDateDisplayFormat = 'l d F Y'
])
->defaultSort('date', 'desc')
->defaultGroup('date')
->configure([
Table::$defaultDateDisplayFormat = 'l d F Y'
])
->defaultSort('date', 'desc')
Is there a possability to format the date display because it shows as Date: 2023-11-25 00:00:00 and want it to be Date: Saturday 25 November 2023? For now my solution is below, but there will be added extra selects for the group that i dont want.
->defaultGroup('date')
->groups([
Tables\Grouping\Group::make('date')
->collapsible(true)
->date(true)
])
->configure([
Table::$defaultDateDisplayFormat = 'l d F Y'
])
->defaultSort('date', 'desc')
->defaultGroup('date')
->groups([
Tables\Grouping\Group::make('date')
->collapsible(true)
->date(true)
])
->configure([
Table::$defaultDateDisplayFormat = 'l d F Y'
])
->defaultSort('date', 'desc')
And als the defaultSort is not working if i apply the group, how can i sort the records with groups?
4 replies
FFilament
Created by Tieme on 11/25/2023 in #❓┊help
Table groups, summaries table but not groups.
Hi All What I am trying to do: I want to summaries in the Table like https://filamentphp.com/docs/3.x/tables/summaries In my Table i use Groups when i summaries, the Groups also summaries My question: Can i use summaries where table has groups but not summaries the groups? Thanks for the time and possible response on my question
4 replies
FFilament
Created by Tieme on 11/7/2023 in #❓┊help
Add ID to modal
Hi All, I have a action that will open a slideover() modal. Is there anyway to add a ID to the modal? I need to change the padding of modalContent in this modal and some other styling within this modal.
public static function OpenAction()
{
return Actions\Action::make('notes')
->icon('heroicon-m-document-duplicate')
->outlined()
->slideOver()
->modalIcon('heroicon-m-document-duplicate')
->modalHeading('All Notes')
->modalDescription(fn ($record) => new HtmlString('For company <strong>'.isset($record->company) ? $record->company->companyname : $record->companyname.'</strong>'))
->modalIconColor('info')
->modalContent(fn ($record) => view('components.notes', [
'record' => $record,
]))
->modalSubmitAction(false)
->modalCancelAction(false)
->modalFooterActions([
self::CreateAction()
])
->stickyModalHeader()
->stickyModalFooter()
->keyBindings(['command+n', 'ctrl+n']);
}
public static function OpenAction()
{
return Actions\Action::make('notes')
->icon('heroicon-m-document-duplicate')
->outlined()
->slideOver()
->modalIcon('heroicon-m-document-duplicate')
->modalHeading('All Notes')
->modalDescription(fn ($record) => new HtmlString('For company <strong>'.isset($record->company) ? $record->company->companyname : $record->companyname.'</strong>'))
->modalIconColor('info')
->modalContent(fn ($record) => view('components.notes', [
'record' => $record,
]))
->modalSubmitAction(false)
->modalCancelAction(false)
->modalFooterActions([
self::CreateAction()
])
->stickyModalHeader()
->stickyModalFooter()
->keyBindings(['command+n', 'ctrl+n']);
}
i know there is
extraAttributes
extraAttributes
but this will only apply to the Action button. Or is it possible to open a view where the modal is in? I did not find anything in https://filamentphp.com/docs/3.x/actions/modals Thanks for reading this question.
5 replies
FFilament
Created by Tieme on 9/25/2023 in #❓┊help
Custom summaries (Sum of other column)
Hi All, I'm looking at https://filamentphp.com/docs/3.x/tables/summaries#custom-summaries For a summary of a different column. I have a table where i show Hours. Only Hours is a attribute in de model and not a column in the tabel. So when i want to Sum the "hours" i get a error 500 that the query is bad. Now i want to summarize this column only with the real column in the database in this case the column is amount that needs to sum. With below settings that i got from Custom summaries the summory wont show anythin it doe not pop-up nor does it gives me a error. ''' TextColumn::make('hours') ->sortable() ->summarize( Summarizer::make() ->label('First last name') ->using(fn (Builder $query): string => $query->sum('amount')) ), ''' Does anyone know how to summarize a different column than the original one? Thanks.
2 replies
FFilament
Created by Tieme on 9/21/2023 in #❓┊help
Relation manager (Hide Table data from table record)
Hi All, I use the table of the (in my case) ProjectResource. In that table i want to hide one or 2 columns in the relation manager table. Example of table. The first Stack::make (with company.companyname and contact.full_name) needs to be vissible on the "ProjectResource" but Hidden in RalationsshipManager return $table ->columns([ Split::make([ Stack::make([ TextColumn::make('company.companyname') ->weight(FontWeight::Bold) ->searchable(), TextColumn::make('contact.full_name'), ])->grow(false), Stack::make([ TextColumn::make('subject') ->weight(FontWeight::Bold) ->searchable(), TextColumn::make('number') ->searchable() ->sortable(), ])->grow(false),
4 replies
FFilament
Created by Tieme on 9/21/2023 in #❓┊help
Relation managers (Hide on edit page)
Hi All, Maybe I looked over it, but how can i hide the Relation tables on the edit page of the parent record? It needs to be vissble only on the view of the parent. Thanks.
10 replies
FFilament
Created by Tieme on 9/18/2023 in #❓┊help
navigation badge icon
No description
11 replies
FFilament
Created by Tieme on 8/26/2023 in #❓┊help
badge default color
Hi All, I am implementing following Badge With Color : https://filamentphp.com/docs/3.x/tables/columns/text#displaying-as-a-badge TextColumn::make('status') ->badge() ->color(fn (string $state): string => match ($state) { 'draft' => 'gray', 'reviewing' => 'warning', 'published' => 'success', 'rejected' => 'danger', }) Is there anyway that i can set a default color if state does not exists? Now it will trohw a exception / error UnhandledMatchError Unhandled match case 'created' Thanks!
6 replies
FFilament
Created by Tieme on 8/25/2023 in #❓┊help
Function for navigationGroup in recource page?
Hi, Is there a function for the navigationGroup so i can translate it just like public function getTitle(): string | Htmlable { return __('test.title.page'); } Thanks!
3 replies
FFilament
Created by Tieme on 8/6/2023 in #❓┊help
Add Notifications to user menu
Hi, I'm new to filamentphp, i realy love how it is. sometimes i have some trouble with the configuration of how things work but that is always when you try a new system. Add the moment i want to add a new menu item to the user menu. Not that difficult, the only thing i want is that it is a "Database notifications" button with "Notifications ({{ $unreadNotificationsCount }} unread)" as label. How can i do this? Maybe i want to add it next to my profile pictore on the top. With a icon and a unread badge, is this possible and how to do this? Thanks!
2 replies