Code A
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