nostrodamned
nostrodamned
FFilament
Created by nostrodamned on 6/4/2024 in #❓┊help
Hot Reloading with Modules
Hi all, I am using laravel modules on a filament project and trying to get hot reloading working this is my vite config
import { defineConfig } from "vite";
import laravel, { refreshPaths } from 'laravel-vite-plugin'
import livewire from '@defstudio/vite-livewire-plugin'; // import plugin
import collectModuleAssetsPaths from "./vite-module-loader.js";

async function getConfig() {
const paths = [
"resources/css/app.css",
"resources/js/app.js",
"resources/css/filament/admin/theme.css",
//add addition module paths here
];
const allPaths = await collectModuleAssetsPaths(paths, "Modules");

return defineConfig({
plugins: [
laravel({
input: allPaths,
}),
livewire({
refresh: [
...refreshPaths, // Tracking changes wherever app.js is called
'app/Http/Livewire/**', // To monitor LiveWire components (if applicable)
'app/Filament/**',
'Modules/**' // To monitor changes in the Modules folder
]
})
],
});
}

export default getConfig;
import { defineConfig } from "vite";
import laravel, { refreshPaths } from 'laravel-vite-plugin'
import livewire from '@defstudio/vite-livewire-plugin'; // import plugin
import collectModuleAssetsPaths from "./vite-module-loader.js";

async function getConfig() {
const paths = [
"resources/css/app.css",
"resources/js/app.js",
"resources/css/filament/admin/theme.css",
//add addition module paths here
];
const allPaths = await collectModuleAssetsPaths(paths, "Modules");

return defineConfig({
plugins: [
laravel({
input: allPaths,
}),
livewire({
refresh: [
...refreshPaths, // Tracking changes wherever app.js is called
'app/Http/Livewire/**', // To monitor LiveWire components (if applicable)
'app/Filament/**',
'Modules/**' // To monitor changes in the Modules folder
]
})
],
});
}

export default getConfig;
I get no errors but hot reloading isnt firing on a change - anyone any ideas?
1 replies
FFilament
Created by nostrodamned on 5/23/2024 in #❓┊help
Having issues with Test using laravel-modules and FilamentPHP
Hi all, I am trying to run this test
test('can register User', function () {
livewire(CreateUser::class)
->fillForm([
'name' => 'John Ford',
'email' => '[email protected]',
'password' => 'password',
'passwordConfirmation' => 'password'
])
->call('create')
->assertHasNoErrors(['name', 'email', 'password', 'passwordConfirmation']);

$this->assertDatabaseHas('users',[
'name' => 'John Doe',
'email' => '[email protected]',
]);
});
test('can register User', function () {
livewire(CreateUser::class)
->fillForm([
'name' => 'John Ford',
'email' => '[email protected]',
'password' => 'password',
'passwordConfirmation' => 'password'
])
->call('create')
->assertHasNoErrors(['name', 'email', 'password', 'passwordConfirmation']);

$this->assertDatabaseHas('users',[
'name' => 'John Doe',
'email' => '[email protected]',
]);
});
to test a user registering I am getting this error if i try the UserCreate class
Modules\Auth\tests\Feature\RegistrationTest > can register User ViewException
Route [filament.admin.resources.users.index] not defined. (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php)
Modules\Auth\tests\Feature\RegistrationTest > can register User ViewException
Route [filament.admin.resources.users.index] not defined. (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php) (View: /Users/craigvonchamier/Herd/TAC/vendor/filament/filament/resources/views/components/page/index.blade.php)
and this if i use the UserClass
FAILED Modules\Auth\tests\Feature\RegistrationTest > can register User ComponentNotFoundException
Unable to find component: [Modules\User\Models\User]
FAILED Modules\Auth\tests\Feature\RegistrationTest > can register User ComponentNotFoundException
Unable to find component: [Modules\User\Models\User]
Anyone any ideas please? Thanks in advance!
10 replies
FFilament
Created by nostrodamned on 4/20/2024 in #❓┊help
Add header Actions to a slideover
Hi all, is it possible to add header actions to an edit form in slideover view?
6 replies
FFilament
Created by nostrodamned on 4/12/2024 in #❓┊help
Best Way to create invoice number preview
TextInput::make('finance_invoice_start_number')
->live(onBlur: true)
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'The starting number for the invoice number. .'),
TextInput::make('finance_invoice_suffix')
->live(onBlur: true)
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'The suffix for the invoice number. For example, if the suffix is "-INV", the invoice number will be "0001-INV".'),
TextInput::make('finance_invoice_number_padding')
->live(onBlur: true)
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'The number of digits to pad the invoice number with. For example, if the padding is "4", the invoice number will be "0001".'),

TextInput::make('finance_invoice_start_number')
->live(onBlur: true)
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'The starting number for the invoice number. .'),
TextInput::make('finance_invoice_suffix')
->live(onBlur: true)
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'The suffix for the invoice number. For example, if the suffix is "-INV", the invoice number will be "0001-INV".'),
TextInput::make('finance_invoice_number_padding')
->live(onBlur: true)
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'The number of digits to pad the invoice number with. For example, if the padding is "4", the invoice number will be "0001".'),

I want to generate a preview of how the invoice number will look upon changint the field values. I can use a livewire component with alpine using this
public function getInvoiceNumberPreviewProperty()
{
$number = str_pad($this->startingNumber, $this->padding, '0', STR_PAD_LEFT);

return "{$this->prefix}{$number}{$this->suffix}";
}
public function getInvoiceNumberPreviewProperty()
{
$number = str_pad($this->startingNumber, $this->padding, '0', STR_PAD_LEFT);

return "{$this->prefix}{$number}{$this->suffix}";
}
but wondering if there is a more elegant way to do it directly in the form?
9 replies
FFilament
Created by nostrodamned on 4/5/2024 in #❓┊help
Add Tenant Profile Page To Cluster?
hi does anyone know how i can add the tenant profile page to a cluster? it seems this doesnt work
<?php

namespace App\Filament\AgencySettings\Clusters\General\Pages;

use App\Filament\AgencySettings\Clusters\General;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\EditTenantProfile;

class AgencyProfile extends EditTenantProfile
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.agency-settings.clusters.general.pages.agency-profile';
protected static ?string $cluster = General::class;

public static function getLabel(): string
{
return 'Agency profile';
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name'),
// ...
]);
}
}
<?php

namespace App\Filament\AgencySettings\Clusters\General\Pages;

use App\Filament\AgencySettings\Clusters\General;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Tenancy\EditTenantProfile;

class AgencyProfile extends EditTenantProfile
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.agency-settings.clusters.general.pages.agency-profile';
protected static ?string $cluster = General::class;

public static function getLabel(): string
{
return 'Agency profile';
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name'),
// ...
]);
}
}
Thanks in advance!
2 replies
FFilament
Created by nostrodamned on 3/19/2024 in #❓┊help
How to make tooltips render html?
I have Html in my translation strings (or i could use markdown) - either way i cannot get it to render in tooltips
RichEditor::make('outcome')
->label(__('Outcome'))
->columnSpanFull()
->required()
->hint(__('What is the expected outcome of this lesson?'))
->hintIcon('heroicon-m-question-mark-circle', tooltip: __('tooltips.outcome_description')),
RichEditor::make('outcome')
->label(__('Outcome'))
->columnSpanFull()
->required()
->hint(__('What is the expected outcome of this lesson?'))
->hintIcon('heroicon-m-question-mark-circle', tooltip: __('tooltips.outcome_description')),
I have tried rendering html strings etc to no avail! Any suggestions?
4 replies
FFilament
Created by nostrodamned on 3/17/2024 in #❓┊help
Redirect loop on tenant with subdomain
I am just setting up tenancy and I am getting an error asdf.tac.test redirected you too many times this is my admin panel provider https://gist.github.com/craigvc/615cfebe692f8d5870ea2a0eca4b9f98 Any clues to what i am doing wrong?
4 replies
FFilament
Created by nostrodamned on 3/9/2024 in #❓┊help
A Call for help! launching Monday! Importing issue with livewire error
No description
42 replies
FFilament
Created by nostrodamned on 2/26/2024 in #❓┊help
Create Macro that uses Get Owner Record for Actions
Hi all i reuse this a lot on Actions
->visible(//only visible if $record organization is the same as the current user's organization
function () {
return $this->getOwnerRecord()->organizations->contains(organization());
}
)
->visible(//only visible if $record organization is the same as the current user's organization
function () {
return $this->getOwnerRecord()->organizations->contains(organization());
}
)
How can i use it on the AppServiceProvider as the getOwnerRecord method is not there?
2 replies
FFilament
Created by nostrodamned on 2/10/2024 in #❓┊help
How do i Remove the * for required fields that use a prefix without a label?
Hi all - may be a silly one but how can i do this? When a field is required it still shows the * above the field - i would like it in the prefix/suffix area? Thanks in advance! I do this for the *
->prefix(function () {
return new HtmlString(__('First Name ').
'<span class="text-danger-600 dark:text-danger-400 font-medium">*</span>');
})
~
->prefix(function () {
return new HtmlString(__('First Name ').
'<span class="text-danger-600 dark:text-danger-400 font-medium">*</span>');
})
~
But issue is the validation * being above the field and messing up the layout
4 replies
FFilament
Created by nostrodamned on 2/5/2024 in #❓┊help
Pass Calling Model on ImportAction from Relation Manager
HI all, Is there a way to pass which ModelId called the Import Action We have a Group Model and we want to know the group_id that the import action was called from in order to save it to a database record?
5 replies
FFilament
Created by nostrodamned on 1/31/2024 in #❓┊help
Open Confirmation Modal before allowing user to Create a new record
Hi all it seems the CreateAction doesnt allow a confirmation modal before showing the user the create form, does anyone know how i could do this? Thanks in advance
4 replies
FFilament
Created by nostrodamned on 12/12/2023 in #❓┊help
How to add action to Group on Rows
Hi is it possible to add an action to a Grouped set of rows (so the button is on the group row)? Thanks in advance!
2 replies
FFilament
Created by nostrodamned on 11/7/2023 in #❓┊help
Custom Field that Extends TextInput etc to AutoSave
I am trying somehow to create a parameter i can pass to a textinput that autosaves a field this is my customclass
<?php
namespace App\Forms\Components;

use Filament\Forms\Components\Field;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Contracts\HasForms;
use Illuminate\Database\Eloquent\Model;

class AutoSaveTextInput extends TextInput
{
// ...

protected bool $autoSave = false;

public function autoSave(bool $value = true): static
{
$this->autoSave = $value;

return $this;
}

public static function handleAfterStateUpdated(Field $component, HasForms $livewire, ?Model $record, mixed $state)
{
if (! $record || ! $component->autoSave) {
return; // If there is nowhere to save or autoSave is false, return.
}

$livewire->validateOnly($component->getStatePath());
$record->update([$component->getName() => $state]);
}
}
<?php
namespace App\Forms\Components;

use Filament\Forms\Components\Field;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Contracts\HasForms;
use Illuminate\Database\Eloquent\Model;

class AutoSaveTextInput extends TextInput
{
// ...

protected bool $autoSave = false;

public function autoSave(bool $value = true): static
{
$this->autoSave = $value;

return $this;
}

public static function handleAfterStateUpdated(Field $component, HasForms $livewire, ?Model $record, mixed $state)
{
if (! $record || ! $component->autoSave) {
return; // If there is nowhere to save or autoSave is false, return.
}

$livewire->validateOnly($component->getStatePath());
$record->update([$component->getName() => $state]);
}
}
I want to add the parameter ->autosave(true) to the field - Something like this
AutoSaveTextInput::make('name')->autofocus()->required()

->columnSpan(6)
->prefix('Task Name*')
->required()
->label('')
->reactive()
->live(true)
->autoSave(true),
AutoSaveTextInput::make('name')->autofocus()->required()

->columnSpan(6)
->prefix('Task Name*')
->required()
->label('')
->reactive()
->live(true)
->autoSave(true),
Any hints on how i can use the afterStateUpdated to call this function? Thanks in advance!!
10 replies
FFilament
Created by nostrodamned on 10/4/2023 in #❓┊help
can anyone spot what i am doing wrong here?
I am trying to display a hyphen if there is no date added to the record this is my code
TextColumn::make('due_date')
->sortable()
->date()
->toggleable()
->color(function ($record) {
$value = $record->due_date;

if ($value === null) {
return $value;
}

$date = \Carbon\Carbon::parse($value);
$now = \Carbon\Carbon::now();

$style = '';
if ($date->isPast()) {
$style = 'danger';
} elseif ($now->diffInWeeks($date) <= 4) {
$style = 'warning';
}
return $style;
})
->formatStateUsing(function ($value, $record) {
if ($value === null) {
return '-';
}
return $value;
}),
TextColumn::make('due_date')
->sortable()
->date()
->toggleable()
->color(function ($record) {
$value = $record->due_date;

if ($value === null) {
return $value;
}

$date = \Carbon\Carbon::parse($value);
$now = \Carbon\Carbon::now();

$style = '';
if ($date->isPast()) {
$style = 'danger';
} elseif ($now->diffInWeeks($date) <= 4) {
$style = 'warning';
}
return $style;
})
->formatStateUsing(function ($value, $record) {
if ($value === null) {
return '-';
}
return $value;
}),
Any ideas where i am going wrong ?
25 replies
FFilament
Created by nostrodamned on 9/21/2023 in #❓┊help
undefined variable $activeTab in listPage Class
I am getting a error undefined variable $activeTab on the list page
<?php

namespace App\Filament\Resources\BookingResource\Pages;

use App\Filament\Resources\BookingResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Pages\ListRecords\Tab;
use Illuminate\Database\Eloquent\Builder;

class ListBookings extends ListRecords
{
//public ?string $activeTab = 'active';
protected static string $resource = BookingResource::class;

public function getTabs(): array
{
return [
'all' => Tab::make(),
'active' => Tab::make(),
'inactive' => Tab::make(),
];
}

public function getDefaultActiveTab(): string | int | null
{
return 'active';
}

protected function getHeaderActions(): array
{
return [
CreateAction::make()->slideOver(),
];
}
}
<?php

namespace App\Filament\Resources\BookingResource\Pages;

use App\Filament\Resources\BookingResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Pages\ListRecords\Tab;
use Illuminate\Database\Eloquent\Builder;

class ListBookings extends ListRecords
{
//public ?string $activeTab = 'active';
protected static string $resource = BookingResource::class;

public function getTabs(): array
{
return [
'all' => Tab::make(),
'active' => Tab::make(),
'inactive' => Tab::make(),
];
}

public function getDefaultActiveTab(): string | int | null
{
return 'active';
}

protected function getHeaderActions(): array
{
return [
CreateAction::make()->slideOver(),
];
}
}
this is my code any ideas?
8 replies
FFilament
Created by nostrodamned on 9/19/2023 in #❓┊help
Spatie Settings multiple groups on one page
Hi All, I am trying to figure out how to do this: I am using Spatie Settings and have multiple groups(global, finance, security etc) How can i save data to multiple groups on a settings page - as i am specifying public static function group(): string { return 'global'; } on each Settings class? eg.
<?php

namespace App\Filament\Settings;
use Spatie\LaravelSettings\Settings;

class GlobalAgencySettings extends Settings
{
public ?string $agency_timezone;

public ?string $agency_date_format;

public ?string $agency_time_format;

public static function group(): string
{
return 'global';
}
}
<?php

namespace App\Filament\Settings;
use Spatie\LaravelSettings\Settings;

class GlobalAgencySettings extends Settings
{
public ?string $agency_timezone;

public ?string $agency_date_format;

public ?string $agency_time_format;

public static function group(): string
{
return 'global';
}
}
I was trying to avoid having one huge settings class 🙂
6 replies
FFilament
Created by nostrodamned on 9/17/2023 in #❓┊help
Thoughts on best practices for a View
I am just looking for some advice/ideas here. My application has multiple different settings such as finance settings, Account settings etc. Each Set of settings is a different resource. I am trying to think of a way to consolidate them to make it easy for user navigation. It would be perfect i think to have a secondary menu so Settings --Finance Settings --Status Settings etc. but that looks messy on the main nav- it would be better to have a settings menu under the user menu, but it doesnt support nested menus. My next thought would be have the Settings on the User Menu link, and have a secondary sidebar on the page, but i cant think of an easy way to do this except make every resource a custom page and add a livewire component to it for the links to the seperate menu items - seems clunky! The last idea i had was to use tabs, but i cant figure a way to load views into tabs for different resources! Any thoughts, ideas, suggestions greatly appreciated!!!
7 replies
FFilament
Created by nostrodamned on 9/17/2023 in #❓┊help
Check for uniqueness according to column title for grouped records
Hi I am trying to check for uniqueness of a Status Title - based on the model type. This is my code (but its probably junk!!)
Forms\Components\TextInput::make('title')
->autofocus()
->required()
->unique(Status::class, 'title',
ignoreRecord: true,
modifyRuleUsing: function (Unique $rule) {
//we want ensure that we have unique titles per model_type when editing the record
$rule->where('model_type', request()->input('record.model_type'));

return $rule;
})
->placeholder(__('Title')),
Forms\Components\TextInput::make('title')
->autofocus()
->required()
->unique(Status::class, 'title',
ignoreRecord: true,
modifyRuleUsing: function (Unique $rule) {
//we want ensure that we have unique titles per model_type when editing the record
$rule->where('model_type', request()->input('record.model_type'));

return $rule;
})
->placeholder(__('Title')),
Basically have 2 columns the model_type and the Title, so want to ensure that title is unique for each model_type (i added the ignoreRecord to allow editing of the title.
2 replies
FFilament
Created by nostrodamned on 9/17/2023 in #❓┊help
Bug in colorPicker in modal
When the colorpicker is in a modal (editRecord) it is pretty unusable, you cant slide the color bar and clicking just instantly closes the picker, is there any workarounds here?
3 replies