Tjiel
Tjiel
FFilament
Created by Tjiel on 10/25/2024 in #❓┊help
How can I change the width of individual statsoverview stats?
Hey all, im trying to have a stats overview widget which consists of 2 stats to take up the full width, the problem is that I can't find out how.
protected function getStats(): array
{
return [
Stat::make('Unique views', '192.1k'),
Stat::make('Bounce rate', '21%'),
];
}
protected function getStats(): array
{
return [
Stat::make('Unique views', '192.1k'),
Stat::make('Bounce rate', '21%'),
];
}
okay if I for example have this basic stat it takes up 2/3 the width of the page. Instead of this I want it so that it takes up full space and not have 2 stats that take up each 1/3th of the page. I already tried to do something with the columspan, but that is for the whole widget, so then each takes 1/3 of the columnspan that has been asigned. If anyone can help me out to individually change the width, so I will be able to make them both take 50% of the width, or any other posible solution, it would be really appreciated.
7 replies
FFilament
Created by Tjiel on 10/22/2024 in #❓┊help
Duplicate query problem when using a relationship in a repeater
Hey all, I have the following repeater:
Repeater::make('answers')
->label('Answers')
->translateLabel()
->relationship('answers')
->schema([
Forms\Components\TextInput::make('name')
->label('Answer')
->translateLabel()
->required()
->maxLength(255)
->default(''),
])->reorderable()->orderColumn('order'),
Forms\Components\Select::make('section_id')
->label('Section')
->translateLabel()
->preload()
->live()
->relationship('section', 'name'),
Repeater::make('answers')
->label('Answers')
->translateLabel()
->relationship('answers')
->schema([
Forms\Components\TextInput::make('name')
->label('Answer')
->translateLabel()
->required()
->maxLength(255)
->default(''),
])->reorderable()->orderColumn('order'),
Forms\Components\Select::make('section_id')
->label('Section')
->translateLabel()
->preload()
->live()
->relationship('section', 'name'),
But the problem is that for each answer the section query is performed instead of it being performed once. Is there a good way to make it so the following query: select * from sections where sections.id = 15 limit 1, is only being made once instead of for each answer once.
2 replies
FFilament
Created by Tjiel on 9/26/2024 in #❓┊help
Spatie tag name text input field
Hello all, I have created a resource for the spatie tag model:
use Spatie\Tags\Tag;

class TagResource extends Resource
{
protected static ?string $model = Tag::class;

protected static ?string $navigationIcon = 'heroicon-o-tag';

public static function form(Form $form): Form
{
return $form
->schema([
Section::make()
->schema([
Forms\Components\TextInput::make('name')
->label('Name')
->translateLabel()
->required()
->unique('name', 'tags')
->maxLength(255),
use Spatie\Tags\Tag;

class TagResource extends Resource
{
protected static ?string $model = Tag::class;

protected static ?string $navigationIcon = 'heroicon-o-tag';

public static function form(Form $form): Form
{
return $form
->schema([
Section::make()
->schema([
Forms\Components\TextInput::make('name')
->label('Name')
->translateLabel()
->required()
->unique('name', 'tags')
->maxLength(255),
I want the user to be able to change the name of the tag, the problem is that it is saved like the following: {"nl": "test"}. So with the above code I get [object Object], and when I try to submit it, I get the following errror: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'database.name' doesn't exist. Then I tried to do the form like this.
Forms\Components\TextInput::make('name.nl')
->label('Name')
->translateLabel()
->required()
->unique('name', 'tags')
->maxLength(255),
Forms\Components\TextInput::make('name.nl')
->label('Name')
->translateLabel()
->required()
->unique('name', 'tags')
->maxLength(255),
This did fill the field with the string I wanted it to fill with, but still the same error ocurs. Any help would be really appreciated.
6 replies
FFilament
Created by Tjiel on 8/28/2024 in #❓┊help
Looking for a way to search table based on custom state
Hello all I have the following Textcolumn:
TextColumn::make('object')
->label('Object')
->translateLabel()
->searchable()
->formatStateUsing(fn ($state): string => $state->name ?? $state->mainObject->name)
TextColumn::make('object')
->label('Object')
->translateLabel()
->searchable()
->formatStateUsing(fn ($state): string => $state->name ?? $state->mainObject->name)
The problem is that currently, when searching, an error occurs. This is because you can obviously not saerch a direct relation. But my question is if there is a work around to make it so you can search for both columns at the same time, in this case the object->name column and the object->mainObject->name column.
6 replies
FFilament
Created by Tjiel on 7/26/2024 in #❓┊help
Accessing the state of the repeater from inside the repeater
Hey all, I am currently working on a form that has a repeater somewhat like this:
Repeater::make('questions')
->label('Questions')
->translateLabel()
->relationship()
->addActionLabel(__('Add question'))
->collapsed()
->schema([
Forms\Components\TextInput::make('name')
->label('Question')
->translateLabel()
->required()
->maxLength(255),
Select::make('required_question')
->label('Required question')
->translateLabel()
->searchable()
->options(function (Get $get) {
$otherQuestions = $get('questions');
// needs to be questions exluding this one
// logic to return data from questions
})
Repeater::make('questions')
->label('Questions')
->translateLabel()
->relationship()
->addActionLabel(__('Add question'))
->collapsed()
->schema([
Forms\Components\TextInput::make('name')
->label('Question')
->translateLabel()
->required()
->maxLength(255),
Select::make('required_question')
->label('Required question')
->translateLabel()
->searchable()
->options(function (Get $get) {
$otherQuestions = $get('questions');
// needs to be questions exluding this one
// logic to return data from questions
})
In the select called required_question I want to reference a different question from the repeater. I was trying to do this by using $get('questions'). But this results just in a null since its looking for a field called 'questions' in the repeater, which obviously does not exist. So the thing I would like to know is how can i get the values of the other questions as options in my required_question? Any help would be really appreciated, if there are any questions about my problem im happy to provide answers.
4 replies
FFilament
Created by Tjiel on 7/15/2024 in #❓┊help
Removal of scrollbar in the sidebar
Hey all, on some smaller screens the resources in my sidebar are to much to be in one view. So a scrollbar appears. Is there any way to make it hidden. I have already tried the following but nothing seems to be happening.
.fi-sidebar::-webkit-scrollbar {
display: none;
}

.fi-sidebar {
-ms-overflow-style: none;
scrollbar-width: none;
}
.fi-sidebar::-webkit-scrollbar {
display: none;
}

.fi-sidebar {
-ms-overflow-style: none;
scrollbar-width: none;
}
Any help would be appreciated!
4 replies
FFilament
Created by Tjiel on 7/11/2024 in #❓┊help
Updating placeholder text afterStateUpdated
Hey all, I currently have. a form where the user can optinally a select a relationship. If the relationship is present it will use the value of the fields from that relationship. Unless the corresponding field is filled in the current form. The problem is that i want to display the values of the relation to the user but not fill the field to do that. So I want to change the placeholder after the state update. currently i have the following:
Select::make('product_id')
->label('Product')
->translateLabel()
->relationship('product', 'name')
->searchable()
->preload()
->live()
->afterStateUpdated(function (callable $set, $state) {
$product = Product::find($state);
$set('name', $product->name);
Select::make('product_id')
->label('Product')
->translateLabel()
->relationship('product', 'name')
->searchable()
->preload()
->live()
->afterStateUpdated(function (callable $set, $state) {
$product = Product::find($state);
$set('name', $product->name);
At the moment it just updates the value. What i want instead is that it will update the placeholder of the name field instead. Is there any way to do this?
6 replies
FFilament
Created by Tjiel on 6/21/2024 in #❓┊help
How can I display a file uploaded using the spatie media library on the info list page
Hey all!, in my filament project I'm making use of of the spatie media library for filament (https://filamentphp.com/plugins/filament-spatie-media-library). Although there is a way to display an image on the infolist, as specified in the documentation. I can not find a way to display non-image files with just a file name and a download button. If anyone knows how I might be able to do this or something else that is similar, please let me know.
2 replies
FFilament
Created by Tjiel on 6/17/2024 in #❓┊help
Embedded youtube video in rich editor
Hey all, I want the user to be able to add an embedded youtube video to the rich editor. Is there any way to do this using the rich editor filament provides, or are there any alternative plugins that offer this functionality.
2 replies
FFilament
Created by Tjiel on 6/11/2024 in #❓┊help
Looking for a way to change the logo based on the tenant.
Hey all, I am currently working on a project with multi tenancy, the tenant is based on the domain. As of now I have done the tenant styling using a middleware I made, here is the start of it:
public function handle(Request $request, Closure $next): Response
{
$tenant = tenant();

if ($tenant) {
if ($tenant->admin_primary_color) {
FilamentColor::register(['primary' => $tenant->admin_primary_color]);
}
public function handle(Request $request, Closure $next): Response
{
$tenant = tenant();

if ($tenant) {
if ($tenant->admin_primary_color) {
FilamentColor::register(['primary' => $tenant->admin_primary_color]);
}
This is working as intended but when I looked up on how to change the logo (preverably in a similar way), I could not find anything. So my question is if anyone knows how I might add functionality to my theming middleware, so I can update the logo using the tenants logo. Of course any recommendations for doing it outside the middleware are also welcome.
4 replies
FFilament
Created by Tjiel on 6/7/2024 in #❓┊help
Is there a way to use the filament colors in a custom theme
Hey all, I am working on a project with multi tenancy and I want to use the tenant's colors to be used in a custom theme. Currently I have a middleware to set the filament colors:
public function handle(Request $request, Closure $next): Response
{
$tenant = tenant();

if ($tenant) {
if ($tenant->admin_primary_color) {
FilamentColor::register(['primary' => $tenant->admin_primary_color]);
}
public function handle(Request $request, Closure $next): Response
{
$tenant = tenant();

if ($tenant) {
if ($tenant->admin_primary_color) {
FilamentColor::register(['primary' => $tenant->admin_primary_color]);
}
This is working great, but the problem i'm having is that I want to change the colors of the sidebar, topbar and more. I already have created a custom theme, here is the start of it:
@import '/vendor/filament/filament/resources/css/theme.css';

@config 'tailwind.config.js';

.fi-sidebar-header, .fi-topbar > nav, .fi-body {
background-color: #EE8225;
}
@import '/vendor/filament/filament/resources/css/theme.css';

@config 'tailwind.config.js';

.fi-sidebar-header, .fi-topbar > nav, .fi-body {
background-color: #EE8225;
}
So basicly my question is, how can I use the registered primary color in the theme.css, so I can for example change the background color of the sidebar.
17 replies
FFilament
Created by Tjiel on 6/5/2024 in #❓┊help
Looking for a way to get a time range value input field
No description
9 replies
FFilament
Created by Tjiel on 5/27/2024 in #❓┊help
How to change capitalization on model label?
Hey all a resource for my model QrCodes, in this model I have set the model label the following way:
public static function getModelLabel(): string
{
return __('QR access code');
}

public static function getPluralModelLabel(): string
{
return __('QR access codes');
}
public static function getModelLabel(): string
{
return __('QR access code');
}

public static function getPluralModelLabel(): string
{
return __('QR access codes');
}
The problem im having is that its displaying Qr Access Codes instead of QR access codes. According to the documentation you can prevent default the default capitalization in the following way:
protected static bool $hasTitleCaseModelLabel = false;
protected static bool $hasTitleCaseModelLabel = false;
https://filamentphp.com/docs/3.x/panels/resources/getting-started#automatic-model-label-capitalization But variable is not reconized and doesn't do anything. So my question is if anybody knows how I might solve this problem.
13 replies
FFilament
Created by Tjiel on 5/21/2024 in #❓┊help
Looking for a way to display files from spatie media library in the infolist.
Hey all, Im currently creating an infolist for a resource that has multiple file uploads, the image uploads I can display fine using the document infolist entry (https://filamentphp.com/plugins/filament-spatie-media-library#infolist-entry). The problem comes when I need to display different files on the infolist. So my question is if there is a way to show these filenames and make them downloadable? and if so, how can I do that?
1 replies
FFilament
Created by Tjiel on 5/13/2024 in #❓┊help
Looking for an openinghours form field in filament
Hey all, Im currently migrating a project from nova to fillament. In my nova project I have the following package for an OpeningHours input field: SadekD\NovaOpeningHoursField\NovaOpeningHoursField. So my question is the following: Is there any good alternative package to do something similar using Filament.
9 replies
FFilament
Created by Tjiel on 4/26/2024 in #❓┊help
Image saved to AWS bucket not displayed on infolist.
Hey all, I have a form with the fileupload:
Forms\Components\FileUpload::make('banner')
->label('Banner')
->translateLabel()
->image()
->acceptedFileTypes(['image/*'])
->maxSize(4096)
->disk('s3')
->directory('events/banners'),
Forms\Components\FileUpload::make('banner')
->label('Banner')
->translateLabel()
->image()
->acceptedFileTypes(['image/*'])
->maxSize(4096)
->disk('s3')
->directory('events/banners'),
When submitting it seems to be working fine, the problem is that whenever I go to the view page, the image is not displaying. When inspecting, the img element doesn't have an src (<img src style="). This is what im trying in my infolist:
ImageEntry::make('banner')
->label('Banner')
->translateLabel()
->disk('s3')
->columnSpan(2),
ImageEntry::make('banner')
->label('Banner')
->translateLabel()
->disk('s3')
->columnSpan(2),
So if anyone knows a possible solution, please let me know. If i should clarify some more, please let me know and I'm happy to do so.
3 replies
FFilament
Created by Tjiel on 4/17/2024 in #❓┊help
How can I make a filter not changeable by the user?
I have filter that has a default value, the problem is that the user can change this filter, which I don't want the user to be able to do. I prefer a way to make it so the user doesn't see there are filters and there is no filter icon to be clicked on. But it would also be good enough if the user just could not change them.
5 replies
FFilament
Created by Tjiel on 4/16/2024 in #❓┊help
Parameter being null after table action
I have a widget that refreshes the page with a custom parameter. I use this parameter to manipulate a different widget, which needs a page refresh. And to update the getTableQuery method.
protected function getTableQuery(): Builder
{
if (Request::query('location')) {
switch (Request::query('location')){
case 'all': return parent::getTableQuery();
case 'allDeleted': {
return Asset::onlyTrashed();
}
default: {
$location = Location::findOrFail(Request::query('location'));
$assetIds = $location->assets->pluck('id')->toArray();
return parent::getTableQuery()->whereIn('id', $assetIds);
}
}
}
dd(Request::query('location'));
$location = Location::first();
if ($location) {
$assetIds = $location->assets->pluck('id')->toArray();
return parent::getTableQuery()->whereIn('id', $assetIds);
}
return parent::getTableQuery();
}
protected function getTableQuery(): Builder
{
if (Request::query('location')) {
switch (Request::query('location')){
case 'all': return parent::getTableQuery();
case 'allDeleted': {
return Asset::onlyTrashed();
}
default: {
$location = Location::findOrFail(Request::query('location'));
$assetIds = $location->assets->pluck('id')->toArray();
return parent::getTableQuery()->whereIn('id', $assetIds);
}
}
}
dd(Request::query('location'));
$location = Location::first();
if ($location) {
$assetIds = $location->assets->pluck('id')->toArray();
return parent::getTableQuery()->whereIn('id', $assetIds);
}
return parent::getTableQuery();
}
This is working fine on the initial loading of the page, as you would expect the Request::query('location') is present and it applies the correct filters. The problem comes when trying to do a table action like delete, restore or any custom action. Then it is null, as i can see using the dd method. Why might this be and how can i make it so it will detect the location.
7 replies
FFilament
Created by Tjiel on 4/12/2024 in #❓┊help
Change default table query to get only the soft deleted records
Hello all, For a project im working on I need my table results to only show the soft deleted records.
protected function getTableQuery(): Builder
{
return parent::getTableQuery();
}
protected function getTableQuery(): Builder
{
return parent::getTableQuery();
}
I want it so that instead of currently returning the default parent::getTableQuery instead a where or something like that that makes it so it only gets soft deleted records.
9 replies
FFilament
Created by Tjiel on 4/11/2024 in #❓┊help
Action on press of record in table?
I have the following actions in my AssetResource:
->actions([
Tables\Actions\Action::make('action')
->label('Action')
->translateLabel()
->action(function () {
// Action logic
}),
DefaultActionGroup::make(),
])
->actions([
Tables\Actions\Action::make('action')
->label('Action')
->translateLabel()
->action(function () {
// Action logic
}),
DefaultActionGroup::make(),
])
Is there a way that instead of creating a text where, when pressed on, performs the action. You can just click on the row of the record. Currently whenever I press on the record it just goes to the view page.
4 replies