Venky
Venky
FFilament
Created by Venky on 10/26/2024 in #❓┊help
Table reload in custom livewire tab by updating in another tab table record.
I have a resource page with Tab implementation. First tab for draft items loaded through livewire page. The second tab is with published items. I wants to refresh the second table when ever I am publishing a record in First tab. Below is the main page
public function getTabs(): array
{return [
'All' => Tab::make('All')->schema([
Livewire::make(ActiveListingTable::class)->key('active-listing-table')
]),
];
}
public function infolist(Infolist $infolist): Infolist
{return $infolist
->schema([
Tabs::make('Tabs')->contained(false)
->tabs([
Tabs\Tab::make('Draft')
->schema([
Livewire::make(DraftListingTable::class)->key('dradt-listing-table')->lazy()
])->extraAttributes([
'x-data' => '{ isActive: false }',
'x-init' => 'isActive = ($el.closest("[role=\'tablist\']").querySelector("[aria-selected=\'true\']") === $el)',
'x-effect' => 'if(isActive) { window.Livewire.emit(\'refreshDraftTable\') }',
'x-on:click' => 'isActive = true',
]),
Tabs\Tab::make('active-tasks')->label('Published')
->schema([
Livewire::make(ActiveListingTable::class)->key('active-listing-table')->lazy()
])->extraAttributes([
'x-data' => '{ isActive: false }',
'x-init' => 'isActive = ($el.closest("[role=\'tablist\']").querySelector("[aria-selected=\'true\']") === $el)',
'x-effect' => 'if(isActive) { window.Livewire.emit(\'refreshActiveTable\') }',
'x-on:click' => 'isActive = true',
]),
]),
]);
}
public function getTabs(): array
{return [
'All' => Tab::make('All')->schema([
Livewire::make(ActiveListingTable::class)->key('active-listing-table')
]),
];
}
public function infolist(Infolist $infolist): Infolist
{return $infolist
->schema([
Tabs::make('Tabs')->contained(false)
->tabs([
Tabs\Tab::make('Draft')
->schema([
Livewire::make(DraftListingTable::class)->key('dradt-listing-table')->lazy()
])->extraAttributes([
'x-data' => '{ isActive: false }',
'x-init' => 'isActive = ($el.closest("[role=\'tablist\']").querySelector("[aria-selected=\'true\']") === $el)',
'x-effect' => 'if(isActive) { window.Livewire.emit(\'refreshDraftTable\') }',
'x-on:click' => 'isActive = true',
]),
Tabs\Tab::make('active-tasks')->label('Published')
->schema([
Livewire::make(ActiveListingTable::class)->key('active-listing-table')->lazy()
])->extraAttributes([
'x-data' => '{ isActive: false }',
'x-init' => 'isActive = ($el.closest("[role=\'tablist\']").querySelector("[aria-selected=\'true\']") === $el)',
'x-effect' => 'if(isActive) { window.Livewire.emit(\'refreshActiveTable\') }',
'x-on:click' => 'isActive = true',
]),
]),
]);
}
12 replies
FFilament
Created by Venky on 9/5/2024 in #❓┊help
How to enable search in custom options
Select::make('products')
->reactive()
->searchable()
->multiple()
->options(function (Get $get, Set $set, ?string $search = null) {
$results = null;
if (!is_null($get('category_id'))) {
$query = DB::table('product_flat')
if ($search) {
$query->where('product_flat.name', 'like', '%' . $search . '%');
}
$products = $query->get();
$productHtmlArray = [];
foreach ($products as $product) {
$priceHtml = $product->special_price && now()->between($product->special_price_from, $product->special_price_to)
? '<span class="text-red-500">$' . htmlspecialchars($product->special_price) . '</span> <span class="line-through text-gray-500">$' . htmlspecialchars($product->price) . '</span>'
: '<span>$' . htmlspecialchars($product->price) . '</span>';
$html = '
<div class="p-4" style="width: 350px;"></div>';
$productHtmlArray[$product->product_id] = $html;
}
return $productHtmlArray;
}
return [];
})
->searchDebounce(500)
->searchResultsLimit(10)
->placeholder('Select Products');
Select::make('products')
->reactive()
->searchable()
->multiple()
->options(function (Get $get, Set $set, ?string $search = null) {
$results = null;
if (!is_null($get('category_id'))) {
$query = DB::table('product_flat')
if ($search) {
$query->where('product_flat.name', 'like', '%' . $search . '%');
}
$products = $query->get();
$productHtmlArray = [];
foreach ($products as $product) {
$priceHtml = $product->special_price && now()->between($product->special_price_from, $product->special_price_to)
? '<span class="text-red-500">$' . htmlspecialchars($product->special_price) . '</span> <span class="line-through text-gray-500">$' . htmlspecialchars($product->price) . '</span>'
: '<span>$' . htmlspecialchars($product->price) . '</span>';
$html = '
<div class="p-4" style="width: 350px;"></div>';
$productHtmlArray[$product->product_id] = $html;
}
return $productHtmlArray;
}
return [];
})
->searchDebounce(500)
->searchResultsLimit(10)
->placeholder('Select Products');
7 replies
FFilament
Created by Venky on 8/9/2023 in #❓┊help
Converting collection to Builder is not giving data.
I have two different table called 'invoices' and 'receipts'. So, I just want to show the both records as a ledger sheet with closing balance amount as last column in the table. I am trying to do this using below. But, it is showing no records found in the table. But, we can see the records in while doing print (dd). Am I doing woring apprroach here. Is there any better way to do this. protected function getTableQuery(): Builder { $invoices = Invoice::select( DB::raw("'invoice' as type"), 'invoices.created_at as date', 'invoices.invoice_amount as amount' ) ->where('invoice_to', Session::get('current_franchisee')) ->orderBy('date'); $receipts = Receipt::select( DB::raw("'receipt' as type"), 'receipts.created_at as date', 'receipts.amount as amount' ) ->where('received_from', Session::get('current_franchisee')) ->orderBy('date'); $transactions = $invoices->union($receipts)->get(); $closing_balance = 0; foreach ($transactions as $k => $transaction) { $closing_balance = ($transaction->type === 'invoice' ? $transaction->amount + $closing_balance : $closing_balance - $transaction->amount); $transactions[$k]->closing_balance = $closing_balance; } return $transactions->toQuery(); } protected function getTableColumns(): array { return [ TextColumn::make('type'), TextColumn::make('amount'), TextColumn::make('closing_balance'), ]; }
7 replies
FFilament
Created by Venky on 7/17/2023 in #❓┊help
filament-sidebar-item-active class is not there in custom pages
Hi all, I am facing an issue where we unable to see the selected menu on screen if we have many. so I installed https://github.com/ibrahimBougaoua/filament-menu-scroll-fix which resolved only for resources not for the custom pages. I don't know What I missed. I found that the custom menus are not having 'filament-sidebar-item-active' class after selection. Can any one guide me to resolve this?
4 replies
FFilament
Created by Venky on 5/30/2023 in #❓┊help
$record is null in selectColumn
I am facing an issue in below code. In 'Status' field I am getting $record collection. But, in 'fee_id' the $record is null. I unable to figure it out.
Tables\Columns\SelectColumn::make('Status')
->options(['Active' => 'Active', 'Hold' => 'Hold', 'Completed' => 'Completed'])
->default(function ($record) {
return $record->status;
}),
Tables\Columns\SelectColumn::make('fee_id')
->options(function ($record) {
$options = CourseFee::where('course_id', $record->course_id)->pluck('name', 'id');
return $options;
}),
Tables\Columns\SelectColumn::make('Status')
->options(['Active' => 'Active', 'Hold' => 'Hold', 'Completed' => 'Completed'])
->default(function ($record) {
return $record->status;
}),
Tables\Columns\SelectColumn::make('fee_id')
->options(function ($record) {
$options = CourseFee::where('course_id', $record->course_id)->pluck('name', 'id');
return $options;
}),
3 replies
FFilament
Created by Venky on 3/28/2023 in #❓┊help
SelectColumn: disable auto update and using selected value in bulk action
I want to use selected value from 'SelectColumn' field and to be used in bulk action without updating the field. Is it possible? I have this scenario in many pages. It will be helpful if some one guide me . Thanks in advance.
7 replies
FFilament
Created by Venky on 3/13/2023 in #❓┊help
Table should be blank in default
Actually I need the table to blank in default. It should be filled only with the search filter result. It should be blank again while using "reset filter". Is this possible?
25 replies