jjo63
jjo63
FFilament
Created by jjo63 on 10/22/2024 in #❓┊help
Adding a record count alongside a navigation link
No description
10 replies
FFilament
Created by jjo63 on 10/21/2024 in #❓┊help
Is it possible to add a badge to top line with a number on it?
I can see in the filament demo there is a bell icon with a number just above - i'd like to implement something similar using a different icon - could anyone point me to what I need to be reading in the documentation? Clicking the bell in the demo opens a slideover with a list of the items contained within - that's what I'd like to be able to implement albeit with a different icon. Thx for pointers, j
4 replies
FFilament
Created by jjo63 on 10/19/2024 in #❓┊help
Edit form without fields
I know, it sounds daft, but I was wondering if the edit form (which I have implemented as a slideover) and from which I have removed the ability to edit any fields can be displayed without field boundaries - there is a default size for each field, some are very short content others are potentially more lengthy text. I wondered if it is possible to apply an attribute that would result in the fields actually not being displayed and whatever content is behind then just being displayed without any length constraints? Is there a different type of resource i should generate and use (and can it be accessed in the same kind of way as a slideover (not critical, but nice)? thx all, j
6 replies
FFilament
Created by jjo63 on 10/17/2024 in #❓┊help
Help! Unable to access variable values from .env
This is really bizarre. And perhaps more of a Laravel question now I think about it. But... My Filament app is able to connect to a database and display e.g. the APP_NAME - so I know that the .env file is present and has been read by Laravel /Filament core code. But - I cannot access the values from within e.g. a Widget. I have this line of code Log::info('APP_NAME:' . env('APP_NAME')); and it results in output [2024-10-17 11:45:50] local.INFO: APP_NAME: Even though the APP_NAME is clearly displayed (and has a value in the .env file) by Filament. All my code which is trying to access other variables (I was just using APP_NAME as an example) has "suddenly stopped working" - and I am thoroughly perplexed. Here is a little routine that proves the existence of the file:

$envFilePath = base_path('.env');

// Check if the .env file exists
if (file_exists($envFilePath)) {
// Open the file for reading
$envFile = fopen($envFilePath, 'r');

// Read each line and echo the contents
while (($line = fgets($envFile)) !== false) {
echo $line; // Output each line with a line break for readability
}

// Close the file after reading
fclose($envFile);
} else {
echo "The .env file does not exist.";
}

echo "FINALLY:" . env('APP_URL') . PHP_EOL;

$envFilePath = base_path('.env');

// Check if the .env file exists
if (file_exists($envFilePath)) {
// Open the file for reading
$envFile = fopen($envFilePath, 'r');

// Read each line and echo the contents
while (($line = fgets($envFile)) !== false) {
echo $line; // Output each line with a line break for readability
}

// Close the file after reading
fclose($envFile);
} else {
echo "The .env file does not exist.";
}

echo "FINALLY:" . env('APP_URL') . PHP_EOL;
But the echo of env('APP_URL') at the end gives nothing. Here is the script's output
$ php test.php APP_NAME="HCAT DB SYSTEM" APP_ENV=local APP_KEY=base64:4xxxxxxxxxxxxxxxx= APP_DEBUG=true APP_URL=https://xxxxxxxxxxxx ... ... ... FINALLY:
Any clues anyone?
18 replies
FFilament
Created by jjo63 on 9/9/2024 in #❓┊help
Application load failure on Safari but OK on Chrome
Hi all, bit of an odd one this. I developed originally using the php server and all was good. I then wanted to make the app accessible to a wider audience for evaluation and so I configured apache and setup SSL etc. The issue occurs on logging in: If I login to the app on Safari using the php server (port 8000) all OK. If I login to the app on Safari using apache (443) I get an error. If I login to the app on Chrome using apache (443) all OK. The error is
The POST method is not supported for route admin/login. Supported methods: GET, HEAD.
Any thoughts or experience of this? thanks j
13 replies
FFilament
Created by jjo63 on 8/27/2024 in #❓┊help
searchable() - accessing the search terms entered / context of results
Hi is it possible to access the search string entered in the free text box? I'm interested in being able to pull out the context of the data where the entered search terms match, It seems like a very clever bit of coding within Filament which enables matching using the entered words even when the words are not consecutive. My objective is to be able to show the user (ideally in a column in the "table view") the underlying data on which the match was made (context). For example the user types in "table mountain" and the context might be "The walkers hiked all the way to the top of Table Mountain in the searing midday heat" - so would be great to be able to pull out x words before and after the search term. Is such a thing possible?
1 replies
FFilament
Created by jjo63 on 8/21/2024 in #❓┊help
Changed behaviour of button after data change in table
Please look at the movie attached. The first time I click the "view document" button the modal pops up - and I can navigate with prev / next buttons through the records in the Filament table. I can close the modal and click a different row's button and the modal reopens. However when I change the data (e.g. apply a filter or page the results) the behaviour changes and the document opens taking the whole browser window (i.e. the modal is no longer used). Any tips on where to look first? thx j
22 replies
FFilament
Created by jjo63 on 8/20/2024 in #❓┊help
Generating some template (e.g. DIV) into a Table resource view
Hi as I understand it there are "render hooks" that can be used to inject some additional content in different places on different types of page. I have a resource called ArchFile and when we present the table of records I'd like (within that page) to be able to include some additional HTML (defines some divs needed for a modal iframe). My knowledge again is inadequate to understand how to achieve this. I was reading here https://filamentphp.com/docs/3.x/support/render-hooks and thought that this would be an appropriate use for my needs:
FilamentView::registerRenderHook(
TablesRenderHook::HEADER_AFTER,
fn (): View => view('my_extra_html'),);
FilamentView::registerRenderHook(
TablesRenderHook::HEADER_AFTER,
fn (): View => view('my_extra_html'),);
The documentation says
To register render hooks, you can call FilamentView::registerRenderHook() from a service provider or middleware.
I am not sure what that means but I'm guessing that my ArchFileResource.php file is not the place. In a default install of Filament, where might i add this code? Thanks for all help & comments, j
4 replies
FFilament
Created by jjo63 on 8/18/2024 in #❓┊help
Styling a custom column
Hi I have a custom column used in a table like this
return $table
->columns([

doclink::make(name: 'sp_file_id')
,
return $table
->columns([

doclink::make(name: 'sp_file_id')
,
I was assuming (wrongly 🙂 ) that I could style it using the options available on text columns (e.g. ->badge() ) but see that this is not valid. Is there a standard way of enabling such styling options? thanks j
3 replies
FFilament
Created by jjo63 on 8/16/2024 in #❓┊help
->description() - is it possible to further style?
Table columns and using the ->description() method (correct term?) for example like this
Tables\Columns\TextColumn::make('name')
->label('Filename')
->description('my description')
->sortable(),
Tables\Columns\TextColumn::make('name')
->label('Filename')
->description('my description')
->sortable(),
Is it possible to apply styling to the description (such as badge and setting a colour)? I don't think that description() supports this natively and am sure that there is a method to further style using some kind of custom code but wouldn't know where to start on this. Any pointers? thx j
6 replies
FFilament
Created by jjo63 on 8/16/2024 in #❓┊help
GetStateUsing - when can it be used? One example that works, one that doesn't
Hi all, GetStateUsing - have found this useful - here is an example of it being used to retrieve the description from an array - and this works beautifully
public static function table(Table $table): Table
{
// populate array of folders
$folders = DB::table('arch_folders')
->orderBy('id')
->pluck('name', 'id')
->toArray();
return $table
->columns([

Tables\Columns\TextColumn::make('name')
->label('Filename')
->description(function ($record, $state) use ($folders) {

return 'Folder: ' . $folders[$record->arch_folder_id] ?? null;
})
->sortable(),
public static function table(Table $table): Table
{
// populate array of folders
$folders = DB::table('arch_folders')
->orderBy('id')
->pluck('name', 'id')
->toArray();
return $table
->columns([

Tables\Columns\TextColumn::make('name')
->label('Filename')
->description(function ($record, $state) use ($folders) {

return 'Folder: ' . $folders[$record->arch_folder_id] ?? null;
})
->sortable(),
In this case we are displaying the name of a file and underneath (in the description) pulling the name of the folder based on its entry in an array $folders I thought that I could make the folder name itself a column by doing this
public static function table(Table $table): Table
{
// populate array of folders


$folders = DB::table('arch_folders')
->orderBy('id')
->pluck('name', 'id')
->toArray();


return $table
->columns([
Tables\Columns\TextColumn::make('Folder')
->label('Folder')
->getStateUsing(function ($record, $state) use ($folders){
return $folders[$record->arch_folder_id] ?? null;
}
),
public static function table(Table $table): Table
{
// populate array of folders


$folders = DB::table('arch_folders')
->orderBy('id')
->pluck('name', 'id')
->toArray();


return $table
->columns([
Tables\Columns\TextColumn::make('Folder')
->label('Folder')
->getStateUsing(function ($record, $state) use ($folders){
return $folders[$record->arch_folder_id] ?? null;
}
),
When I run this version the browser just hangs eventually saying it's unable to get a response - and the php http server will not respond to any other requests until I kill & restart it. Is my use of GetStateUsing in example 2 incorrect? No errors reported in storage/logs/laravel.log nor in the php http server output. thanks - not critical (I can workaround) but thought I'd flag it to see if it's my error or ..., j
6 replies
FFilament
Created by jjo63 on 8/14/2024 in #❓┊help
Filament Tables - listwithlinebreaks() - what am I doing wrong?
No description
6 replies
FFilament
Created by jjo63 on 8/6/2024 in #❓┊help
Hide Resources from Panel
Hi I am sure this is simple but cannot see how this is achieved. Say I have a resource "pets" - I get a number of php dfiles generated for this and a link is added to the admin panel - this all happens automatically. I'm doing POC stuff and I'd like to keep what I have (code for reference) but not have the resources cluttering up my admin panel - what's the method (short of deleting the files) to remove them from the view of the user? I guess one option would be to create a new Laravel app 🙂 or to create a new admin panel - but just wanted to know if there is a simple way to achieve the hiding of resources that you don't actually want to see? thanks j
4 replies
FFilament
Created by jjo63 on 7/29/2024 in #❓┊help
Using jquery within a blade in Filament
No description
2 replies
FFilament
Created by jjo63 on 7/29/2024 in #❓┊help
Generic process for installing plugins?
Hi a little confused - I wanted to use this plugin https://github.com/solutionforest/Filament-SimpleLightBox I ran the composer command
composer require solution-forest/filament-simplelightbox
composer require solution-forest/filament-simplelightbox
No problems. I modified my file app/Providers/Filament/AdminPanelProvider.php to add the line referencing the plugin
class AdminPanelProvider extends PanelProvider
{

public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')

<snip of default code>

->plugin(SimpleLightBoxPlugin::make())
;
}
}
class AdminPanelProvider extends PanelProvider
{

public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->path('admin')

<snip of default code>

->plugin(SimpleLightBoxPlugin::make())
;
}
}
When I tried to reload my app, I get an error Class "App\Providers\Filament\SimpleLightBoxPlugin" not found As there were no other installation / pre-req usage instructions I wondered whether this is me being ignorant of some typical steps you'd follow or if this is actually an issue with the installation of the plugin. Any pointers? thanks j
6 replies
FFilament
Created by jjo63 on 7/26/2024 in #❓┊help
Odd "jumping" behaviour when using a toggle
No description
18 replies
FFilament
Created by jjo63 on 7/25/2024 in #❓┊help
Grouping records in a table
No description
3 replies
FFilament
Created by jjo63 on 7/25/2024 in #❓┊help
ToggleColumn - making conditionally invisible
Hi I have the following code snippet
ToggleColumn::make('is_indexed')
->label('Index?')
->onColor('info')
->beforeStateUpdated(function ($record, $state) {

// Runs before the state is saved to the database.
})
->afterStateUpdated(function ($record, $state) {
// Runs after the state is saved to the database.
})
->visible(function ($record) {
dd($record->record_type);

})
ToggleColumn::make('is_indexed')
->label('Index?')
->onColor('info')
->beforeStateUpdated(function ($record, $state) {

// Runs before the state is saved to the database.
})
->afterStateUpdated(function ($record, $state) {
// Runs after the state is saved to the database.
})
->visible(function ($record) {
dd($record->record_type);

})
In the
beforeStateUpdated
beforeStateUpdated
I can access $record - but within
visible
visible
I am unable to (i.e. generates an error - "Attempt to read property "record_type" on null"). I don't understand why $record isn't universally available to me - but accepting that's the case, how would I access the current record within the
visible
visible
method so that I can determine whether the toggle should be shown or not? thanks for your help! j
8 replies
FFilament
Created by jjo63 on 5/22/2024 in #❓┊help
Basic navigation from row in "parent" list to table of "children"
No description
1 replies
FFilament
Created by jjo63 on 5/18/2024 in #❓┊help
Invalid SQL Generated when using Relation Manager
Hi folks, I was interested to explore this. I issued this command
MyPropertyResource my_property_rooms room_name
MyPropertyResource my_property_rooms room_name
and then registered the relation. When I execute the app I am getting this SQL being generated:
SELECT
count(*) AS aggregate
FROM
`my_property_rooms`
WHERE
`my_property_rooms`.`my_property_my_property_id` = 6
AND `my_property_rooms`.`my_property_my_property_id` IS NOT NULL
SELECT
count(*) AS aggregate
FROM
`my_property_rooms`
WHERE
`my_property_rooms`.`my_property_my_property_id` = 6
AND `my_property_rooms`.`my_property_my_property_id` IS NOT NULL
It should read like this
SELECT
count(*) AS aggregate
FROM
`my_property_rooms`
WHERE
`my_property_rooms`.`my_property_id` = 6
AND `my_property_rooms`.`my_property_id` IS NOT NULL
SELECT
count(*) AS aggregate
FROM
`my_property_rooms`
WHERE
`my_property_rooms`.`my_property_id` = 6
AND `my_property_rooms`.`my_property_id` IS NOT NULL
I cannot see where it's looking when generating the SQL that could result in it determining that there is a column called
my_property_my_property_id
my_property_my_property_id
Anyone able to help? thx J
14 replies