QCTFW
QCTFW
FFilament
Created by QCTFW on 7/6/2024 in #❓┊help
Disable Default Sort while Searching with Scout
I use Laravel Scout with Meilisearch for table search. I want to sort the table based on Meilisearch's rank but defaultSort() overrides the Meilisearch's rank. How to disable the defaultSort() while on search?
$table
->selectCurrentPageOnly()
->defaultSort('name', 'asc')
->searchDebounce('500ms')
->columns([...])
->filters([...])
->actions([...]);
$table
->selectCurrentPageOnly()
->defaultSort('name', 'asc')
->searchDebounce('500ms')
->columns([...])
->filters([...])
->actions([...]);
protected function applySearchToTableQuery(Builder $query): Builder
{
$this->applyColumnSearchesToTableQuery($query);

if (filled($search = $this->getTableSearch())) {
$meiliBuilder = Book::search($search);

$query->whereIn('id', $meiliBuilder->keys());

// Already tried this but still not working
$this->tableSortColumn = null;
$this->tableSortDirection = null;
}

return $query;
}
protected function applySearchToTableQuery(Builder $query): Builder
{
$this->applyColumnSearchesToTableQuery($query);

if (filled($search = $this->getTableSearch())) {
$meiliBuilder = Book::search($search);

$query->whereIn('id', $meiliBuilder->keys());

// Already tried this but still not working
$this->tableSortColumn = null;
$this->tableSortDirection = null;
}

return $query;
}
4 replies
FFilament
Created by QCTFW on 7/5/2024 in #❓┊help
Can I define an extra searchable column without creating a column in the table?
So I want a column to be searchable but I defined the column in the description method.
TextColumn::make('book.name')
->label('Book')
->lineClamp(2)
->description(fn (BookBorrow $record) => str('`' . $record->book->isbn . '`')->inlineMarkdown()->toHtmlString())
->searchable()
->sortable()
TextColumn::make('book.name')
->label('Book')
->lineClamp(2)
->description(fn (BookBorrow $record) => str('`' . $record->book->isbn . '`')->inlineMarkdown()->toHtmlString())
->searchable()
->sortable()
How to make the value isbn also searchable?
6 replies
FFilament
Created by QCTFW on 6/3/2024 in #❓┊help
How to add big buttons to dashboard?
No description
6 replies
FFilament
Created by QCTFW on 9/14/2023 in #❓┊help
How to Open Another Modal from Action Modal?
Hello! So I want to build an import excel with Actions. After the user successfully imported the file, I want to automatically close the import modal and open another modal to display the result of the import. How to do that? If it is not possible, how to put some text under the form to display the result? Here is my current code of the import action.
Actions\Action::make('import')
->icon('heroicon-m-arrow-up-tray')
->label('Import')
->color('info')
->form([
Forms\Components\FileUpload::make('file')
->label('Excel file')
// ->...
->required()
])
->action(function ($data) {
// Do the import thing

// Close this modal and open another modal for displaying the import result
})
Actions\Action::make('import')
->icon('heroicon-m-arrow-up-tray')
->label('Import')
->color('info')
->form([
Forms\Components\FileUpload::make('file')
->label('Excel file')
// ->...
->required()
])
->action(function ($data) {
// Do the import thing

// Close this modal and open another modal for displaying the import result
})
7 replies
FFilament
Created by QCTFW on 9/13/2023 in #❓┊help
Confirmation Alert Before Creating a Record
Hello, I want to add a confirmation alert before creating a record in Order model. I already tried this code in CreateOrder class but still does not working, the form got submitted without a confirmation alert. Do I missed something? How to solve this?
<?php

namespace App\Filament\Resources\OrderResource\Pages;

use App\Filament\Resources\OrderResource;
use Filament\Actions\Action;
use Filament\Resources\Pages\CreateRecord;

class CreateOrder extends CreateRecord
{
protected static string $resource = OrderResource::class;

protected function getCreateFormAction(): Action
{
return parent::getCreateFormAction()
->requiresConfirmation();
}
}
<?php

namespace App\Filament\Resources\OrderResource\Pages;

use App\Filament\Resources\OrderResource;
use Filament\Actions\Action;
use Filament\Resources\Pages\CreateRecord;

class CreateOrder extends CreateRecord
{
protected static string $resource = OrderResource::class;

protected function getCreateFormAction(): Action
{
return parent::getCreateFormAction()
->requiresConfirmation();
}
}
12 replies
FFilament
Created by QCTFW on 9/12/2023 in #❓┊help
Access Relationship Input in mutateFormDataBeforeCreate()
Hello, I want to access the relationship inputs in the mutateFormDataBeforeCreate() method, but I can only access the non-relationship inputs. How to do that?
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['cashier_id'] = auth()->id();
return $data;
}
protected function mutateFormDataBeforeCreate(array $data): array
{
$data['cashier_id'] = auth()->id();
return $data;
}
// Data Result
[
"discount" => 10 // from TextInput
"cashier_id" => "01ha16anrawwd9pknhfy3g43yx"
]
// Data Result
[
"discount" => 10 // from TextInput
"cashier_id" => "01ha16anrawwd9pknhfy3g43yx"
]
6 replies