daar
daar
FFilament
Created by daar on 8/15/2024 in #❓┊help
Conditional rules not working
Hi, I want to enable custom rules conditionally, but this is not being called. What am I missing here? I have attached the code used below.
Forms\Components\Select::make('identification_type')
->label(__('Identification type'))
->options(IdentificationType::class)
->live()
->required(), Forms\Components\TextInput::make('citizen_service_number')
->label(__('Identification number'))
->rules([
static fn (Get $get): Closure => static function (string $attribute, $value, Closure $fail) use ($get): void {
if ($get('identification_type') === IdentificationType::CEDULA->value) {
$cedula = new Cedula($value);
if ( ! $cedula->isValid()) {
$fail(__('The citizen service number is invalid'));
}
}
},
])
->maxLength(255),
Forms\Components\Select::make('identification_type')
->label(__('Identification type'))
->options(IdentificationType::class)
->live()
->required(), Forms\Components\TextInput::make('citizen_service_number')
->label(__('Identification number'))
->rules([
static fn (Get $get): Closure => static function (string $attribute, $value, Closure $fail) use ($get): void {
if ($get('identification_type') === IdentificationType::CEDULA->value) {
$cedula = new Cedula($value);
if ( ! $cedula->isValid()) {
$fail(__('The citizen service number is invalid'));
}
}
},
])
->maxLength(255),
9 replies
FFilament
Created by daar on 1/11/2024 in #❓┊help
Resize image in SpatieMediaLibraryFileUpload
Hello, I find Spatie's package excellent, especially for defining conversions to resize uploaded images. However, I'm wondering if there's a way to convert the original file before it gets placed on the server, thus skipping the conversions. The issue is that the original file remains publicly accessible, and I'd like to prevent that. Regards, Darius
10 replies
FFilament
Created by daar on 1/6/2024 in #❓┊help
Show blade page security + integrate into filament panel
I've integrated a simple invoicing feature into my app (see the web route below). I'd love to get insights from experts on two points: 1. Is the auth middleware I've applied sufficient to secure this route? 2. I've been trying to link a blade view with Filament. However, using a ViewField, seems to disrupt the layout by moving the navigation sidebar and top bar drastically. I believe this is likely due to a CSS issue. If I aim to integrate this into Filament, is there a way to separate the CSS within the blade view itself (and not interfere with the filament CSS classes), or are there tools available that can help?
Route::get('/emr/invoice', function (Request $request) {

$invoice = Invoice::find($request->id);
$items = $invoice->payments;

return view('invoices.default', compact('invoice', 'items'));
})
->name('/emr/invoice')
->middleware('auth');
Route::get('/emr/invoice', function (Request $request) {

$invoice = Invoice::find($request->id);
$items = $invoice->payments;

return view('invoices.default', compact('invoice', 'items'));
})
->name('/emr/invoice')
->middleware('auth');
1 replies
FFilament
Created by daar on 12/30/2023 in #❓┊help
Relation Manager dependency
I've got a relation manager, and I'm looking to introduce a dependency. This would narrow down the visible records it shows to only those attachable items where the customer matches the one associated with the record I'm aiming to attach it to. Consider this example: The invoice requires payments to be linked, specifically those associated with the selected customer for this particular invoice.
5 replies
FFilament
Created by daar on 12/27/2023 in #❓┊help
Creating a more ordered admin panel
Hi, I've been working on an application that extensively uses Filament for about a year or so. At first v2, but I recently switched to v3. The application uses 54 tables and in total 34 menu entries. I ordered them, but the submenus are too long for practical use. I have two options I wanted to consider for my admin resource (10 items) but I'm not sure what the most practical is: 1. make use of a second menu bar inside the pages for each resource e.g. aymanalhattami/filament-page-with-sidebar 2. make use of tabs that per tab show the CRUD actions for the resources Any advice would be appreciated. I am playing with the plugin mentioned in #1, but I don't know how to hide the resources from the main menu though. TIA!
6 replies
FFilament
Created by daar on 12/27/2023 in #❓┊help
Searchable and sortable on polymorph
Hi, how to implement a search based on a polymorphic relation with a relationship one down even? With the following code I get the error for sorting: Call to a member function getRelated() on null.
On searching I get:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.'first_name' like ? or 'consultable'.'patientStatus'.'patient'.'last_name' like' at line 1
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.'first_name' like ? or 'consultable'.'patientStatus'.'patient'.'last_name' like' at line 1
Seems like a bug in Filament? The code used is shown below:
Tables\Columns\TextColumn::make('consultable.patientStatus.patient.full_name')
->searchable(['consultable.patientStatus.patient.first_name', 'consultable.patientStatus.patient.last_name'])
->sortable(['consultable.patientStatus.patient.first_name', 'consultable.patientStatus.patient.last_name']),
Tables\Columns\TextColumn::make('consultable.patientStatus.patient.full_name')
->searchable(['consultable.patientStatus.patient.first_name', 'consultable.patientStatus.patient.last_name'])
->sortable(['consultable.patientStatus.patient.first_name', 'consultable.patientStatus.patient.last_name']),
2 replies
FFilament
Created by daar on 12/25/2023 in #❓┊help
Create pest tests
The following code gives a 404, which I don't understand why.
it('has admission-prices page', function () {
$response = $this->get('admission-prices');

$response->assertStatus(200);
});
it('has admission-prices page', function () {
$response = $this->get('admission-prices');

$response->assertStatus(200);
});
My URL is: http://localhost/emr/admission-prices Any suggestions?
5 replies
FFilament
Created by daar on 12/24/2023 in #❓┊help
Foldable side-menu
In Filament 2, the side menu had an automatic folding feature, which isn't available in v3. Is there a method to fold the menu or am I missing something obvious? TIA!
3 replies
FFilament
Created by daar on 12/19/2023 in #❓┊help
Hide SelectColumn based on soft delete status
I want to hide a column, as per the title. See the code below. This has worked before within the project, but I in this case get the error: Argument #1 ($record) must be of type App\Models\Payment, null given. Any suggestions?
Tables\Columns\SelectColumn::make('payment_method')
->visible(fn (Payment $record) => $record->deleted_at),
Tables\Columns\SelectColumn::make('payment_method')
->visible(fn (Payment $record) => $record->deleted_at),
15 replies
FFilament
Created by daar on 12/16/2023 in #❓┊help
Builder query for polymorphic relations
I would like to create a custom filter with a custom query as shown below. The query needs to follow the payable polymorphic relationship on the active record and on that relationship check if the consulable_type is of a specific class. Tables\Filters\Filter::make('consult') ->query( function (Builder $query) { return $query->whereHas('payable', function ($query) { $query->where('consultable_type', '=', WardConsult::class); }); } ), When activating this filter, I get the error: Class "App\Models\Unknown" not found. Does anyone know an active example or could help me fix this code? TIA!
3 replies
FFilament
Created by daar on 12/5/2023 in #❓┊help
Accessing the active record in a Relation Manager
I would like to access the record from within a Relation Manager. This works for a Resource Manager, but in this case, it seems to fail. Any suggestions?
Tables\Actions\EditAction::make()
->visible(
function (ConsultNote $consultNote) {
return $consultNote->created_by == auth()->user()->id &&
$consultNote->created_at->diffInHours() < 24;
}
),
Tables\Actions\EditAction::make()
->visible(
function (ConsultNote $consultNote) {
return $consultNote->created_by == auth()->user()->id &&
$consultNote->created_at->diffInHours() < 24;
}
),
10 replies
FFilament
Created by daar on 8/12/2023 in #❓┊help
add navigation badge to relationship managers
Hi, as per the title of the issue, is it possible to add a navigation badge to relationship managers, just as it is possible to do so in the navigation menu? I could not find anything in the documentation on this. TIA! Darius
2 replies