Mikail
badge color is not reactive on table
TextInputColumn::make('test_2'),
TextColumn::make('total')
->badge()
->color(fn (string $state): string => $state <= $failedGrade ? 'danger' : '')
I have a testinput like this that update the total column. Total column get updated but badge color does not get updated until page reload.
Any way to make badge color also reactive on table?8 replies
Filament filters my leftJoin
I am applying a leftjoin to my filter base query so that records from the left table will populate regardless of whether there's a corresponding record in the right table. The query is fine after log, but something seems to be preventing the leftjoin to work as intended. Here's the code:
->baseQuery(function (Builder $query, array $data): Builder {
$query->from('subjects')
->leftJoin('subject_allocations', function ($join) use ($data) {
$join->on('subjects.id', '=', 'subject_allocations.subject_id');
if (isset($data['school_class_id']) && isset($data['section_id'])) {
$join->where('subject_allocations.school_class_id', $data['school_class_id'])
->where('subject_allocations.section_id', $data['section_id']);
}
});
Log::info($query->toSql(), $query->getBindings());
return $query;
})
7 replies
'id' column with join
I'm having a Column 'id' in where clause is ambiguous when i use join to filter the query:
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->join('enrollments', 'users.id', '=', 'enrollments.user_id')
->leftJoin('applications', 'users.id', '=', 'applications.user_id')
->select(
'users.*',
'enrollments.section_id',
'enrollments.school_class_id',
'enrollments.status',
'applications.application_id',
'applications.class_of_entry_id',
'applications.screening_mark',
'applications.screening_status'
)
->where('users.role_id', Role::STUDENT);
}
The database doesn't know which column to choose the 'id' from. This only gives error in edit and view $operation. Any help to fix this??6 replies
Spatie Settings
How do you make spatie-laravel-settings-plugin tenant aware. Where we can save setting based on different tenant. I tried to add the tenant school_id to the settings migration but I'm facing difficulties with default properties value. Any help?
7 replies
->updateStateUsing on ToggleColumn
There must be an active record no matter what in the resource which works fine in the database with a modification using ->updateStateUsing as shown in code below. The only issue is that toggle button won't go back to 'on' in the view until browser refresh.
Anything I could do?
ToggleColumn::make('status')
->label('Active')
->updateStateUsing(function ($record, $state) {
if (!$state) {
$schoolId = Filament::getTenant()->id;
$hasOtherActive = $record::where('id', '!=', $record->id)
->where('school_id', $schoolId)
->where('status', true)
->exists();
if (!$hasOtherActive) {
Notification::make()
->danger()
->title('Update Failed')
->body('There must be at least one active session.')
->send();
return $state = true;
}
} else {
return $record->update(['status' => $state]);
}
})
6 replies
Can multiple users share the same tenants in multi-tenancy?
Is it possible for multiple users to have access to the same multiple tenants from the panel?
And secondly, could we have a single login page with multiple Auth system where users are simply directed to their own panel based on role. This is to avoid multiple login page.
Would appreciate any idea on this...
8 replies
native(false) won't work on depended dropdown, any idea?
->filters([
SelectFilter::make('school_class_and_section')
->form([
Select::make('school_class_id')
->label('Class')
->relationship('school_classes', 'name')
->native(false)
->live(),
Select::make('section_id')
->label('Section')
// ->native(false) NOTE: Not loading the dropdown unless native is true because sections dropdown depends on classes
->placeholder(fn (Get $get): string => empty($get('school_class_id')) ? 'First select a class' : 'Select an option') ->relationship( 'sections', 'name', fn (Builder $query, Get $get) => $query ->where('sections.school_class_id', $get('school_class_id')) ), ]) Select::make('section_id') won't load if native() is set to false. I think because of arrow fn. The Remove item feature in native(false) is very important in this regard. Any idea how to go around this?
->placeholder(fn (Get $get): string => empty($get('school_class_id')) ? 'First select a class' : 'Select an option') ->relationship( 'sections', 'name', fn (Builder $query, Get $get) => $query ->where('sections.school_class_id', $get('school_class_id')) ), ]) Select::make('section_id') won't load if native() is set to false. I think because of arrow fn. The Remove item feature in native(false) is very important in this regard. Any idea how to go around this?
17 replies