Matthew
Matthew
FFilament
Created by Matthew on 1/3/2025 in #❓┊help
Filters not returning data in query when using ->multiple()
No description
26 replies
FFilament
Created by Matthew on 12/17/2024 in #❓┊help
JSON relationship column in table
I have a table with a JSON column, like this:
Schema::create('filament-latex', function (Blueprint $table) {
$table->id();
// ...
$table->json('collaborators_id')->nullable();
// ...
$table->timestamps();
});
Schema::create('filament-latex', function (Blueprint $table) {
$table->id();
// ...
$table->json('collaborators_id')->nullable();
// ...
$table->timestamps();
});
In my model, I cast it as an array:
protected $fillable = ['collaborators_id']; /// other columns omitted
protected $table = 'filament-latex';
protected $casts = [
'collaborators_id' => 'array',
];
protected $fillable = ['collaborators_id']; /// other columns omitted
protected $table = 'filament-latex';
protected $casts = [
'collaborators_id' => 'array',
];
And in my resource table,
TextColumn::make('collaborators')
->label('Collaborators')
->visible(! config('filament-latex.avatar-columns'))
->badge()
->color('info'),
TextColumn::make('collaborators')
->label('Collaborators')
->visible(! config('filament-latex.avatar-columns'))
->badge()
->color('info'),
Using tinker, the column is saved on my table like this:
collaborators_id: "["4","5"]",
collaborators_id: "["4","5"]",
How should I define my relationship such that the resource table shows the name of the users? I havent used relationships that much so Im a bit confused 😅
4 replies
FFilament
Created by Matthew on 12/14/2024 in #❓┊help
Fileupload doesnt save original name in attachment_file_names
I have this action:
public function uploadAction(): Action
{
return Action::make('upload')
// ...
->form([
FileUpload::make('upload')
->disk(...)
->visibility('private')
->storeFileNamesIn('attachment_file_names')
->directory(...),
]);
}
public function uploadAction(): Action
{
return Action::make('upload')
// ...
->form([
FileUpload::make('upload')
->disk(...)
->visibility('private')
->storeFileNamesIn('attachment_file_names')
->directory(...),
]);
}
But after successfully uploading the file, the record is null. I did set attachment_file_names as a json collumn in my migration, I added it in the $fillable array and its casting to array
57 replies
FFilament
Created by Matthew on 12/10/2024 in #❓┊help
Cant download file from storage
I have created a file in a directory using makeDirectroy(). Then Im trying to download it using storage::download(), response->file(), response->download(), I ALSO tried using controller but none of them are working either... Im very stuck and confused... I have a private storage if you're wondering
public function downloadDocument()
{
// setting variables

if (! $storage->exists($recordID . '/compiled')) {
$storage->makeDirectory($recordID . '/compiled');
}

// Build the command
$command = [
// ...
];

// Execute the command using Symfony Process
$process = new Process($command);
$process->setTimeout(30);

try {
$process->mustRun();
} catch (ProcessFailedException $exception) {
throw new RuntimeException('compilation failed: ' . $exception->getMessage());
}

$pdfPath = $recordID . '/compiled/main.pdf';

if (! $storage->exists($pdfPath)) {
throw new RuntimeException('PDF file does not exist after compilation.');
}

return Storage::download($pdfPath);
}
public function downloadDocument()
{
// setting variables

if (! $storage->exists($recordID . '/compiled')) {
$storage->makeDirectory($recordID . '/compiled');
}

// Build the command
$command = [
// ...
];

// Execute the command using Symfony Process
$process = new Process($command);
$process->setTimeout(30);

try {
$process->mustRun();
} catch (ProcessFailedException $exception) {
throw new RuntimeException('compilation failed: ' . $exception->getMessage());
}

$pdfPath = $recordID . '/compiled/main.pdf';

if (! $storage->exists($pdfPath)) {
throw new RuntimeException('PDF file does not exist after compilation.');
}

return Storage::download($pdfPath);
}
Does it have to do with permissions or something?
60 replies
FFilament
Created by Matthew on 12/9/2024 in #❓┊help
Using Getters in forms
When using Get $get in forms, and you want to get the value of lets say a component that is AFTER the component that has the getter, it will return null. For example:
TextInput::make('author_name')
->label('Author')
->disabled()
->dehydrated()
->formatStateUsing(fn (Get $get) => dd($get('author_id')))
->required(),
Hidden::make('author_id')
->label('Author')
->default(fn () => Auth::id())
->required(),
TextInput::make('author_name')
->label('Author')
->disabled()
->dehydrated()
->formatStateUsing(fn (Get $get) => dd($get('author_id')))
->required(),
Hidden::make('author_id')
->label('Author')
->default(fn () => Auth::id())
->required(),
Is this intended? I assume the components in the form are processed linearly, but wouldnt it be better for the Getter to check all the components and not just the ones that "have already been processed"?
35 replies
FFilament
Created by Matthew on 12/8/2024 in #❓┊help
Tailwind class not found in plugin
I have a page on my plugin, and I want to use the rounded-r-lg class. However, its not applied which makes me think that its not found by tailwind. Am I missing somethign? I dont have any css files in my plugin
39 replies
FFilament
Created by Matthew on 12/5/2024 in #❓┊help
How to "rerender" custom elememts in blade using alpinejs
I will try to explain this the best I can. Assume I have this blade file:
<x-filament-panels::page>
<x-filament::section>
<div
class="grid grid-flow-col justify-stretch gap-4"
x-data="{ message: '' }"
>
<div
x-model="message"
x-ignore
ax-load
ax-load-src="{{ ... }}"
x-data="codeEditor()"
>
</div>
<customEl x-ref="container" x-text="message"></customEl>
</div>
</x-filament::section>
</x-filament-panels::page>
<x-filament-panels::page>
<x-filament::section>
<div
class="grid grid-flow-col justify-stretch gap-4"
x-data="{ message: '' }"
>
<div
x-model="message"
x-ignore
ax-load
ax-load-src="{{ ... }}"
x-data="codeEditor()"
>
</div>
<customEl x-ref="container" x-text="message"></customEl>
</div>
</x-filament::section>
</x-filament-panels::page>
Everytime message is changed, I want to rerender customEl. Due to the nature of that component, just having x-text isnt enough. As I said it needs to be rerendered, but Im not sure how I can approach this. Any ideas?
5 replies
FFilament
Created by Matthew on 12/2/2024 in #❓┊help
Issue with reordable table
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name'),
TextColumn::make('email'),
])
->filters([
//
])
->actions([
Impersonate::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
])
->reorderable('name', true);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name'),
TextColumn::make('email'),
])
->filters([
//
])
->actions([
Impersonate::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
])
->reorderable('name', true);
}
34 replies
FFilament
Created by Matthew on 11/19/2024 in #❓┊help
Use HeaderAction to upload file in FileUpload.
Assume I have a fileupload component in a form on my page. By pressing a header action, is it possible to upload that file (to the specified disk)? Generally when you upload something, before you press create, that file is sitting in the livewire-tmp directory, and its only when you press "Create" that the file goes to its proper directory. In this case, we dont have a create action or a model.
4 replies
FFilament
Created by Matthew on 11/15/2024 in #❓┊help
Plugin development: JS file net::ERR_ABORTED 404 (Not Found)
<?php

namespace TheThunderTurner\FilamentLatex;

use Filament\Support\Assets\AlpineComponent;
use Filament\Support\Facades\FilamentAsset;
use Livewire\Livewire;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class FilamentLatexServiceProvider extends PackageServiceProvider
{
public static string $name = 'filament-latex';

public function configurePackage(Package $package): void
{
$package->name(static::$name)
->hasViews()
->hasTranslations();
}

public function packageBooted(): void
{
Livewire::component('filament-latex', FilamentLatex::class);

FilamentAsset::register(
assets: [
AlpineComponent::make('filament-latex', __DIR__ . '/../resources/dist/filament-latex.js'),
],
package: 'thethunderturner/filament-latex'
);
}
}
<?php

namespace TheThunderTurner\FilamentLatex;

use Filament\Support\Assets\AlpineComponent;
use Filament\Support\Facades\FilamentAsset;
use Livewire\Livewire;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class FilamentLatexServiceProvider extends PackageServiceProvider
{
public static string $name = 'filament-latex';

public function configurePackage(Package $package): void
{
$package->name(static::$name)
->hasViews()
->hasTranslations();
}

public function packageBooted(): void
{
Livewire::component('filament-latex', FilamentLatex::class);

FilamentAsset::register(
assets: [
AlpineComponent::make('filament-latex', __DIR__ . '/../resources/dist/filament-latex.js'),
],
package: 'thethunderturner/filament-latex'
);
}
}
export default function clockWidget() {
return {
time: new Date().toLocaleTimeString(),
init() {
setInterval(() => {
this.time = new Date().toLocaleTimeString();
}, 1000);
}
}
}
export default function clockWidget() {
return {
time: new Date().toLocaleTimeString(),
init() {
setInterval(() => {
this.time = new Date().toLocaleTimeString();
}, 1000);
}
}
}
<x-filament-panels::page>
<x-filament::section>
<x-slot name="heading">
Test
</x-slot>

<div
x-ignore
ax-load
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('filament-latex', 'thethunderturner/filament-latex') }}"
x-data="clockWidget()"
class="text-center"
>
<p class="text-xl" x-text="time"></p>
</div>
</x-filament::section>
</x-filament-panels::page>
<x-filament-panels::page>
<x-filament::section>
<x-slot name="heading">
Test
</x-slot>

<div
x-ignore
ax-load
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('filament-latex', 'thethunderturner/filament-latex') }}"
x-data="clockWidget()"
class="text-center"
>
<p class="text-xl" x-text="time"></p>
</div>
</x-filament::section>
</x-filament-panels::page>
56 replies
FFilament
Created by Matthew on 11/15/2024 in #❓┊help
How to set up hscrollbar
How can I setup a "divider" that resizes two divs by dragging left/right just like in tailwind playground?
3 replies
FFilament
Created by Matthew on 11/14/2024 in #❓┊help
FileUpload max size validation isnt working
FileUpload::make('server')
->maxSize(102400)
->disk('<...>')
->visibility('private'),
FileUpload::make('server')
->maxSize(102400)
->disk('<...>')
->visibility('private'),
if I upload a file of size > 12MB, it gets rejected for being too large. However, post_max_size,memory_limit,max_upload_size,upload_max_filesize in the ini file are all over 128MB, and the validation, still considers 12MB as the limit. Am I missing something?
3 replies
FFilament
Created by Matthew on 11/14/2024 in #❓┊help
Section label doesnt override default value
Im not sure if this is intentional or not, but setting a ->label() to a section does not override the name of Section::make('something'). Is this intentional, if so why?
2 replies
FFilament
Created by Matthew on 11/14/2024 in #❓┊help
Action is always loading when running a laravel process
No description
13 replies
FFilament
Created by Matthew on 11/11/2024 in #❓┊help
Is there a better way to write this x-init?
Is there a better way to write this: x-init="@this.call('loadCastData')" in a blade file? Currently prettier has some issues with the syntax of the quotes.
16 replies
FFilament
Created by Matthew on 8/25/2024 in #❓┊help
How can I add alpine plugin to my filament plugin?
I have the following js file:
import sort from '@alpinejs/sort'
document.addEventListener('alpine:init', () => {
window.Alpine.plugin(sort)
})

export default function widgetList({ options }) {
return {

};
}
import sort from '@alpinejs/sort'
document.addEventListener('alpine:init', () => {
window.Alpine.plugin(sort)
})

export default function widgetList({ options }) {
return {

};
}
blade:
<x-filament-widgets::widget>
<x-filament::section>
<div
x-ignore
ax-load
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('widget-list', 'thethunderturner/widget-list') }}"
x-data="widgetList({
options: @js($options),
})">
<ul x-sort>
<li x-sort:item>foo</li>
<li x-sort:item>bar</li>
<li x-sort:item>baz</li>
</ul>
</div>
</x-filament::section>
</x-filament-widgets::widget>
<x-filament-widgets::widget>
<x-filament::section>
<div
x-ignore
ax-load
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('widget-list', 'thethunderturner/widget-list') }}"
x-data="widgetList({
options: @js($options),
})">
<ul x-sort>
<li x-sort:item>foo</li>
<li x-sort:item>bar</li>
<li x-sort:item>baz</li>
</ul>
</div>
</x-filament::section>
</x-filament-widgets::widget>
However, the list doesnt sort? For some reason it seems the plugin is not applied. What am I missing?
6 replies
FFilament
Created by Matthew on 8/14/2024 in #❓┊help
Allowed memory size of 134217728 bytes exhausted (tried to allocate 31817560 byte
How can I fix this error? Im using a forked version of filament because I working on a PR. (Since v4 doesnt build yet im testing it on v3) Everything was working fine until suddenly I got this message. I was playing around with table.js. When this happened I reverted back to HEAD and I still get this error. I cleared laravel cache, views and I even restarted and I still get the error. Does anyone have an Idea?
5 replies
FFilament
Created by Matthew on 8/7/2024 in #❓┊help
How can I get started with a JS field?
I want to create my own filament field (Slider) which is based on JS nouislider This is currently an Issue on github for filament 4.1. I want to get a jumpstart on this, and even if it doesnt get merged, at least I learned something new 😅 The problem is I have NO IDEA how to get started with javascript plugins. For starters, I added nouislider in the package.json. Furthermore, I've also create the Slider class, blade and JS file as follows: packages/forms/src/Components/Slider.php
<?php

namespace Filament\Forms\Components;

use Filament\Support\Concerns\HasExtraAlpineAttributes;

class Slider extends Field
{
use HasExtraAlpineAttributes;

/**
* @var view-string
*/
protected string $view = 'filament-forms::components.slider';

protected function setUp(): void
{
parent::setUp();
}
}
<?php

namespace Filament\Forms\Components;

use Filament\Support\Concerns\HasExtraAlpineAttributes;

class Slider extends Field
{
use HasExtraAlpineAttributes;

/**
* @var view-string
*/
protected string $view = 'filament-forms::components.slider';

protected function setUp(): void
{
parent::setUp();
}
}
packages/forms/resources/js/components/slider.js
export default function sliderFormComponent({ start = [20,80], min=0, max=100 }) {
return {
slider: null,

init: function () {
this.slider = document.getElementById('slider')

noUiSlider.create(this.slider, {
start: start,
connect: true,
range: {
'min': min,
'max': max
}
})
}
}
}
export default function sliderFormComponent({ start = [20,80], min=0, max=100 }) {
return {
slider: null,

init: function () {
this.slider = document.getElementById('slider')

noUiSlider.create(this.slider, {
start: start,
connect: true,
range: {
'min': min,
'max': max
}
})
}
}
}
packages/forms/resources/views/components/slider.blade.php
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<div
id="slider"
x-data="sliderFormComponent({ start: [20, 80], min: 0, max: 100 })"
x-init="init()"
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('slider', 'filament/forms') }}">
</div>
</x-dynamic-component>
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<div
id="slider"
x-data="sliderFormComponent({ start: [20, 80], min: 0, max: 100 })"
x-init="init()"
ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('slider', 'filament/forms') }}">
</div>
</x-dynamic-component>
In the create page, I have the Slider field, but when the page is loaded I get this error: Alpine component with ID [slider] not found for package [filament/forms]. What am I missing? Can anyone help?
22 replies
FFilament
Created by Matthew on 8/1/2024 in #❓┊help
filament contribution
No description
21 replies
FFilament
Created by Matthew on 8/1/2024 in #❓┊help
Why is filament clone so large?
No description
6 replies