Kleis
Kleis
FFilament
Created by Kleis on 8/1/2024 in #❓┊help
User administration for tenants
I would like to have a page where the tenants can manage their members, ie. change role/profile information and invite new members. If I simply make a resource for the Organization model (which is my tenant model) and make a relationshipManager on that, then I can access the organization and modify the user and pivot attribute. But I want the tenants to be able to do that also, but obviously only for their current tenant... Any ideas how to do this the best way?
4 replies
FFilament
Created by Kleis on 8/31/2023 in #❓┊help
Hide widget on dashboard
I probably overlooked something simple, how can we hide a widget from the dashboard ? I made a stats widget for a page, but its not supposed to be shown on the dashboard aswell, but the dashboard ofcause shows all widgets in the widget folder so ...
11 replies
FFilament
Created by Kleis on 8/14/2023 in #❓┊help
Label on global search
Is it possible to add a placeholder for global search, to indicate the ctrl+k command to get there? For users that don't just know 🙂
3 replies
FFilament
Created by Kleis on 8/11/2023 in #❓┊help
File upload not showing after reload
I have added a FileUpload field.
FileUpload::make('photos')
->disk('public')
->directory(function(\App\Models\Apartment $record) { return 'apartments/'.$record->name.'/photos/'; })
->preserveFilenames()
->multiple()
->reorderable()
FileUpload::make('photos')
->disk('public')
->directory(function(\App\Models\Apartment $record) { return 'apartments/'.$record->name.'/photos/'; })
->preserveFilenames()
->multiple()
->reorderable()
When I try to upload a image, it shows the progress bar correcly, then a preview of the uploaded image, when I save the page the file is stored correctly in the directory requested and the database field is updated.
-rw-r--r-- 1 semweb users 341K Aug 11 10:27 Peugeot_e-208_dynamic_front34.jpg
photos: "["apartments\/A\/photos\/\/Peugeot_e-208_dynamic_front34.jpg"]",
-rw-r--r-- 1 semweb users 341K Aug 11 10:27 Peugeot_e-208_dynamic_front34.jpg
photos: "["apartments\/A\/photos\/\/Peugeot_e-208_dynamic_front34.jpg"]",
photos is text field and has array cast in the model However when I reload the admin page the image is not shown anymore, and theres no resource failed to load in the network monitor. Any ideas ?
7 replies
FFilament
Created by Kleis on 8/7/2023 in #❓┊help
How to access current model in custom view page
I made a livewire component and included it in a view page, but how can I access the current model in order to show the related data ? Basically I want to make table of the relation with links to edit that relation, but to keep the edit page clean I dont want to include a relation manager there.
class ViewApartment extends Component implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;

public function table(Table $table): Table
{
return $table
->query(function (\App\Models\Apartment $record) { \Log::debug($record); return \App\Models\Ownership::where("apartment_name", $record->name); })
->columns([
TextColumn::make('name'),
])
->filters([])
->actions([])
->bulkActions([]);
}

public function render()
{
return view('livewire.view-apartment');
}
}
class ViewApartment extends Component implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;

public function table(Table $table): Table
{
return $table
->query(function (\App\Models\Apartment $record) { \Log::debug($record); return \App\Models\Ownership::where("apartment_name", $record->name); })
->columns([
TextColumn::make('name'),
])
->filters([])
->actions([])
->bulkActions([]);
}

public function render()
{
return view('livewire.view-apartment');
}
}
6 replies
FFilament
Created by Kleis on 8/4/2023 in #❓┊help
Dynamic text/header in RelationshipManager modal
Is there anyway we can achive a dynamic content for a PlaceHolder field, based on the current record (not the owner record) ? Ie. I want a header of sorts that is based on the data extracted in mountUsing()
return \Filament\Tables\Actions\Action::make('Anvendelse')
->mountUsing(function (Forms\ComponentContainer $form, \App\Models\Ownership $record) {
return $form->fill([
'test' => $record->created_at,
]);
})
->form(
[
Placeholder::make('apartment1')->content($rm->ownerRecord),
Forms\Components\TextInput::make('test'),
])
;
return \Filament\Tables\Actions\Action::make('Anvendelse')
->mountUsing(function (Forms\ComponentContainer $form, \App\Models\Ownership $record) {
return $form->fill([
'test' => $record->created_at,
]);
})
->form(
[
Placeholder::make('apartment1')->content($rm->ownerRecord),
Forms\Components\TextInput::make('test'),
])
;
9 replies
FFilament
Created by Kleis on 8/1/2023 in #❓┊help
Beta 22 seems to break TableWidget
Anyone else stumped on this ? A fairly simple tableWidget stopped working at beta22 with the error "Typed property Filament\Widgets\TableWidget::$table must not be accessed before initialization"
<?php

namespace App\Filament\Widgets;

use Closure;
use Filament\Tables;
use Filament\Widgets\TableWidget as BaseWidget;
use Illuminate\Database\Eloquent\Builder;

class OpenOrders extends BaseWidget
{
protected static ?int $sort = 10;

protected function getTableQuery(): Builder
{
return \App\Models\Order::where("status_id", 2)->orderBy('id', 'desc');
}

protected function getTableColumns(): array
{
return [
Tables\Columns\TextColumn::make('id')->label('#'),
Tables\Columns\TextColumn::make('full_name')->label(__('Name')),
];
}
}
<?php

namespace App\Filament\Widgets;

use Closure;
use Filament\Tables;
use Filament\Widgets\TableWidget as BaseWidget;
use Illuminate\Database\Eloquent\Builder;

class OpenOrders extends BaseWidget
{
protected static ?int $sort = 10;

protected function getTableQuery(): Builder
{
return \App\Models\Order::where("status_id", 2)->orderBy('id', 'desc');
}

protected function getTableColumns(): array
{
return [
Tables\Columns\TextColumn::make('id')->label('#'),
Tables\Columns\TextColumn::make('full_name')->label(__('Name')),
];
}
}
4 replies
FFilament
Created by Kleis on 7/31/2023 in #❓┊help
Make table fixed?
I may have overlooked this in the docs, is there a way to specify a table should ude table-fixed class instead of table-auto? Or is the correct solution so override the tag using the fi class and custom CSS? (I want all columns to have same width)
6 replies
FFilament
Created by Kleis on 7/29/2023 in #❓┊help
Using a theme seems to discard default styles?
I want to use a few tailwind classes that are not in the standard build, so from the documentation I understand I need to make a theme. So I made a simple theme just to run the recompile, and added it to webpack config and reran the npm run prod step. After npm run prod I can now use the custom colors and classes that I needed, but a lot of the default styling is lost, ie. the tabs no longer work and buttons become white on white. Is there something I am missing ?
import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
presets: [preset],
content: [
'./app/Filament/**/*.php',
'./resources/views/**/*.blade.php',
'./vendor/filament/**/*.blade.php',
],
}
import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
presets: [preset],
content: [
'./app/Filament/**/*.php',
'./resources/views/**/*.blade.php',
'./vendor/filament/**/*.blade.php',
],
}
9 replies
FFilament
Created by Kleis on 7/26/2023 in #❓┊help
Make table update when variable changes
Custom page with a livewire component that has a table needs to update the table when a variable changes. There are more parts to the issue, but it boils down to the code below, when changeVar is called from livewire component the var changes (can be seen on the page), but the table header does not. If I click the button once more, the table updates - so the table is always lagging 1 event.
<?php

namespace App\Livewire;

use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Table;
use Illuminate\Contracts\View\View;
use Livewire\Component;
use Filament\Tables\Columns\ViewColumn;

class TableTest extends Component implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;

public $var = "test";

function changeVar()
{
$this->var = "changed";
}

public function table(Table $table): Table
{
return $table
->query(\App\Models\Apartment::where('name', '!=', 'O')->where('name', '!=', 'P'))
->columns([
TextColumn::make('name')->label($this->var),
])
->filters([
// ...
])
->actions([
// ...
])
->bulkActions([
// ...
])->paginated(false);
}

public function render()
{
return view('livewire.table-test');
}
}
<?php

namespace App\Livewire;

use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Table;
use Illuminate\Contracts\View\View;
use Livewire\Component;
use Filament\Tables\Columns\ViewColumn;

class TableTest extends Component implements HasForms, HasTable
{
use InteractsWithTable;
use InteractsWithForms;

public $var = "test";

function changeVar()
{
$this->var = "changed";
}

public function table(Table $table): Table
{
return $table
->query(\App\Models\Apartment::where('name', '!=', 'O')->where('name', '!=', 'P'))
->columns([
TextColumn::make('name')->label($this->var),
])
->filters([
// ...
])
->actions([
// ...
])
->bulkActions([
// ...
])->paginated(false);
}

public function render()
{
return view('livewire.table-test');
}
}
`
14 replies
FFilament
Created by Kleis on 7/11/2023 in #❓┊help
Dynamic title in tabs
Is there a way to bind the tap headers in a modal to dynamic data from the record/mountUsing ? This part "Tabs\Tab::make('Tab1')->schema([" Gist : https://gist.github.com/MORA99/6362fac65e6fcfff26b810e91bf060fc
2 replies