Code A
How to Display a "New User" Option When Searching for Users in Filament?
I am using Filament's Select component with the searchable() feature to allow searching for users with specific roles. I want to implement the following behavior:
1. Always show a "New User" option at the bottom of the list when searching for users.
2. If the user being searched for is not found, the "New User" option should still appear.
How can I achieve this while maintaining the searchable() functionality of Filament's Select component?
8 replies
Route [login] not defined Error After Password Update in Filament
After implementing a profile edit feature in Filament, I'm encountering an issue where updating the password leads to session loss and a "Route [login] not defined" error. does anyone have the same problem?
14 replies
Remove Dashboard Page
How do I remove the default dashboard page from filament and how when login is directed to another route, for example route products?
I have deleted or ->pages in AdminPanelProvider but why does the Dashboard Menu still appear
16 replies
How to synchronize filters between Livewire components in Filament Dashboard Custome Page?
i'm working on a Filament dashboard that displays orders and their locations on a map. I have two Livewire components: ListOrders and AddressMapWidget.
in dashboard-order.blade.php
@vite('resources/css/app.css')
<x-filament-panels::page>
<div class="">
@livewire('widgets.address_map_widget')
@livewire('list-orders',)
</div>
</x-filament-panels::page>
his component filters orders by date (today or yesterday) using buttons. Here is a simplified version of the component:
class ListOrders extends Component
{
public $activeDate = 'today'; // Default active date is 'today'
public function setActiveDate($date)
{
$this->activeDate = $date;
}
public function getFilteredOrder()
{
$dateFilter = $this->activeDate === 'yesterday' ? Carbon::yesterday() : Carbon::today();
// Additional logic
}
public function render()
{
return view('livewire.list-orders', [
'orders' => $this->getFilteredOrders(),
]);
}
}
AddressMapWidget
This component shows markers on the map for the addresses of the orders. Here is a simplified version of the component:
class AddressMapWidget extends MapWidget
{
protected function getData(): array
{
$orders = Order::with('address')->get();
$data = [];
foreach ($orders as $order) {
$data[] = [
'location' => [
'lat' => $order->address->lat ?? 0,
'lng' => $order->address->lng ?? 0,
],
'label' => 'Address (' . $order->address->address . ')',
];
}
return $data;
}
}
I want the map in AddressMapWidget to update automatically when the filter is changed in ListOrders, showing only markers that match the selected date. How can I make these components communicate so the map updates based on the date filter in ListOrders? Are there best practices for this in Filament or Livewire?5 replies
Give default value to TextInput when Edit Data
This data is not in the same table so I have to get the data first in another table
Now from the data I took I want to give a default value in TextInput::make('custom_name')
How do I do that?
class OrderResource extends Resource
{
public static function form(Form $form): Form
{
$data = $form->getRecord();
if ($data !== null) {
$getData = User::find($data->partner_id);
}
return $form
->schema([
// ... form other
Forms\Components\TextInput::make('custom_name)
->label('Name')
->required(),
]) } } The data I took I put in the $getData variable, in the $getData variable there is a name, now I want to give it to the default TextInput custom_name
]) } } The data I took I put in the $getData variable, in the $getData variable there is a name, now I want to give it to the default TextInput custom_name
16 replies