spacedev
spacedev
FFilament
Created by spacedev on 10/3/2024 in #❓┊help
Use Filament Table Filters With Sushi
Hello, I created a simple resource and my table has these filters. ->filters([ Filter::make('Period') ->form([ Flatpickr::make('from') ->default(Carbon::now()->format('Y-m')) ->monthSelect() ->beforeOrEqual('to') ->maxDate(now()->firstOfMonth()) ->required(true), Flatpickr::make('to') ->default(Carbon::now()->format('Y-m')) ->monthSelect() ->afterOrEqual('from') ->maxDate(now()->lastOfMonth()) ->required(), ]) ->default() ->columns(2) In the Manage Class I have overridden the method getTableQuery() to set from and to variable in the Model and use them in the Sushi getRows() method. protected function getTableQuery(): ?Builder { if(isset($this->tableFilters['Period']['from']) && isset($this->tableFilters['Period']['to'])){ ModelName::setPeriod($this->tableFilters['Period']['from'],$this->tableFilters['Period']['to']); } return ModelName::query(); } This is my model class Name extends Model { use \Sushi\Sushi; protected static $from; protected static $to; public function getRows() { info(self::$from); info(self::$to); // The query } public static function setPeriod($from, $to): Builder { self::$from = $from; self::$to = $to; return self::query(); } protected function sushiShouldCache() { return false; } } When I set the from and to dates using the filter, data is filtered using the previous value of these filters instead of the current one. Any suggestions?
2 replies
FFilament
Created by spacedev on 6/18/2024 in #❓┊help
Setting the default value of a TextInput within a Repeater
Hello, I'm trying to set the default value of TextInput within a Repeater using another field outside this repeater. This is a simplified example of what I'm doing, unfortunately I'm not getting the value of cap field. Any suggestions? public static function form(Form $form): Form { return $form ->schema([ HiddenInput::make('cap'), Repeater::make('numbers') ->schema([ TextInput::make('prefix')->default(fn (Get $get) => $get('../../cap')), // I will add a query that will use the value to retrieve data from DB ]) ]); }
19 replies
FFilament
Created by spacedev on 3/11/2024 in #❓┊help
Database Notifications Not Working
Hello, I'm using Database Notifications in the afterSave() method of my Resourse Edit Class and in the afterCreate() method of the Create class. It was working great but now it's not working anymore. It does not create any record in the database and it's not returning any errors. Any suggestions? Thank you!
11 replies
FFilament
Created by spacedev on 2/21/2024 in #❓┊help
Issue with ExportAction on table with defaultSort() on a relationship attribute
Hello, while trying to export this table data we get this error: Next Illuminate\Database\QueryException: SQLSTATE[42P10]: Invalid column reference: 7 ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions LINE 1: select distinct on ("reseller_prices"."id") * from "reseller_prices" where "reseller_prices"."rate_reseller_id" = 2 and "reseller_prices"."rate_reseller_id" is not null order by (select "destination" from "destinations" where "reseller_prices"."destination_id" = "destinations"."id") asc limit 100 offset 0 Are we missing something or is this a BUG? Thanks This is our code (Models involved and Resource Table). class ResellerPrice extends Model { use HasFactory; /** * The attributes that aren't mass assignable. * * @var array */ protected $guarded = []; public function destination(): BelongsTo { return $this->belongsTo(Destination::class); } } public function table(Table $table): Table { return $table ->recordTitleAttribute('id') ->columns([ TextColumn::make('destination.destination') ->sortable(), TextColumn::make('destination.description') ->sortable(), TextColumn::make('price'), TextColumn::make('connection_charge'), TextColumn::make('billing_increment') ]) ->defaultSort('destination.destination') ->filters([ // ]) ->headerActions([ ExportAction::make() ->exporter(ResellerPriceExporter::class) ->formats([ ExportFormat::Xlsx, ExportFormat::Csv, ]), ]) ->actions([ // ]) ->bulkActions([ // ]); } }
5 replies
FFilament
Created by spacedev on 2/21/2024 in #❓┊help
Export Error SQLSTATE[25P02]
Hello, is anyone facing this error using Filament ExportAction? SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block I'm using PostgreSQL and QUEUE_CONNECTION=sync.
4 replies
FFilament
Created by spacedev on 2/19/2024 in #❓┊help
Interact with uploaded file after form submission
Hello, how can I interact with file after the form, with uploaded field, has been submitted?
5 replies
FFilament
Created by spacedev on 12/12/2023 in #❓┊help
Preserve collapsed table row state and table scroll position
Hello, I have a table with collapsible rows with the edit button. Each time I click the edit button the edit form is displayed (as expected), but when I submit or cancel the form the getRedirectUrl() takes me back to the index page, but I lose the isCollapsed state and the initial scroll position. I would like to know if there is a way to preserve these data when coming back to the index page from the edit page. Thank you in advance for your help.
1 replies