F
Filament14mo ago
Damien

How do I replace the default view with my widgets?

I have built (mostly) the 2 widgets that I want to display on my resource and they are looking fine. However, I am struggling to find in the documentation where I can hide the default view which for me, is the same wizard that is used to create a resource.
38 Replies
bwurtz999
bwurtz99914mo ago
Can you provide some more information? When you say "hide the default view" do you mean that the only things you want displayed are the two widgets you've created?
toeknee
toeknee14mo ago
In the AppPanelProvider you can config it with: ->widgets([ ]) and in here you manually register the widgets you want to show.
bwurtz999
bwurtz99914mo ago
But it sounds like these are being displayed on a resource page, not the Dashboard
Damien
DamienOP14mo ago
That is correct yes. So I have a 'Contact' resource. When I view the resource, I don't want to see the original form used to create contact, I want to see my 2 widgets only.
toeknee
toeknee14mo ago
Correct, they auto-register on the dashboard So use the above snippet
Damien
DamienOP14mo ago
sorry, I didn't explain properly, this is not for the dashboard. it is for a resource I have created.
toeknee
toeknee14mo ago
Sorry, do you have the widgets showing on both dashboard and resource?
Damien
DamienOP14mo ago
let me grab a screen shot one moment
Damien
DamienOP14mo ago
excuse the zoomed-out view, I needed to fit it all in.
No description
bwurtz999
bwurtz99914mo ago
I think you'll need a custom view to accomplish this
Damien
DamienOP14mo ago
ah ok. I will take a look at the docs for custom views! Oh thanks for the link!
bwurtz999
bwurtz99914mo ago
and then add the widget to the view
bwurtz999
bwurtz99914mo ago
If you want to keep the standard routing, you can create the custom page and then alter the 'view' route so that it directs to your custom page and not the standard one but that's just personal preference
Damien
DamienOP14mo ago
Awesome thank you so much! I will have a crack at it in the morning. Coming back to this, I've set up a custom page and I've also added a custom theme to help with styling but when trying to render the widget I am getting the following
Damien
DamienOP14mo ago
No description
Damien
DamienOP14mo ago
I did have it working initially but undone it as I couldn't get theming working and now I have, I managed to break this. It could be because I published a custom layout in the first attempt? is there a way to undo this?
Dan Harrin
Dan Harrin14mo ago
@livewire not @Livewire
Damien
DamienOP14mo ago
oh bugger me copilot got me If I have the following Widget class
class ContactOverview extends Widget
{
protected static string $view = 'filament.resources.contact-resource.widgets.contact-overview';

public ?Model $record = null;
}
class ContactOverview extends Widget
{
protected static string $view = 'filament.resources.contact-resource.widgets.contact-overview';

public ?Model $record = null;
}
which previously allowed me to access the record within the blade component file, how do I do the same but for a custom page as $record is now null?
Dan Harrin
Dan Harrin14mo ago
pass the record as a param to the lw component
Damien
DamienOP14mo ago
ah ok, like
@livewire(\App\Filament\Resources\ContactResource\Widgets\ProjectOverview::class, ['contact' => $record])
@livewire(\App\Filament\Resources\ContactResource\Widgets\ProjectOverview::class, ['contact' => $record])
or maybe not, undefined variable.
Dan Harrin
Dan Harrin14mo ago
['record' => $record]
Damien
DamienOP14mo ago
still doesn't seem to like that for some reason
Dan Harrin
Dan Harrin14mo ago
what error
Damien
DamienOP14mo ago
Undefined variable $record
<x-filament-panels::page>
<div class="flex space-x-4">
<div class="flex-grow">
@livewire(\App\Filament\Resources\ContactResource\Widgets\ProjectOverview::class, ['record' => $record])
</div>
<div class="flex-grow">
@livewire(\App\Filament\Resources\ContactResource\Widgets\ContactOverview::class)
</div>
</div>
</x-filament-panels::page>
<x-filament-panels::page>
<div class="flex space-x-4">
<div class="flex-grow">
@livewire(\App\Filament\Resources\ContactResource\Widgets\ProjectOverview::class, ['record' => $record])
</div>
<div class="flex-grow">
@livewire(\App\Filament\Resources\ContactResource\Widgets\ContactOverview::class)
</div>
</div>
</x-filament-panels::page>
Here are my widgets
Dan Harrin
Dan Harrin14mo ago
send your page class
Damien
DamienOP14mo ago
sure 1 second.
<?php

namespace App\Filament\Resources\ContactResource\Pages;

use App\Filament\Resources\ContactResource;
use Filament\Resources\Pages\Page;

class ViewContact extends Page
{
protected static string $resource = ContactResource::class;

protected static string $view = 'filament.resources.contact-resource.pages.view-contact';
}
<?php

namespace App\Filament\Resources\ContactResource\Pages;

use App\Filament\Resources\ContactResource;
use Filament\Resources\Pages\Page;

class ViewContact extends Page
{
protected static string $resource = ContactResource::class;

protected static string $view = 'filament.resources.contact-resource.pages.view-contact';
}
Dan Harrin
Dan Harrin14mo ago
so where is your record being stored so it can be passed in you need to extend ViewRecord
Damien
DamienOP14mo ago
Previusly it was in the ContactResource like this:
<?php

namespace App\Filament\Resources\ContactResource\Widgets;

use Filament\Widgets\Widget;
use Illuminate\Database\Eloquent\Model;

class ContactOverview extends Widget
{
protected static string $view = 'filament.resources.contact-resource.widgets.contact-overview';

public ?Model $record = null;
}
<?php

namespace App\Filament\Resources\ContactResource\Widgets;

use Filament\Widgets\Widget;
use Illuminate\Database\Eloquent\Model;

class ContactOverview extends Widget
{
protected static string $view = 'filament.resources.contact-resource.widgets.contact-overview';

public ?Model $record = null;
}
That is how it worked before I needed the custom route.
Dan Harrin
Dan Harrin14mo ago
yes you need somewhere to actually store the contact which ViewRecord will give you in the easiest way
Damien
DamienOP14mo ago
Ok, I apprecaite your patience. This is a bit of a mindshift coming from React/Next apps
Dan Harrin
Dan Harrin14mo ago
if you need an explanation, have a look at how livewire full page components work outside of filament for sure its a shift, but its just a lack of knowledge with how Livewire works nothing that cant be fixed
Damien
DamienOP14mo ago
learning laravel and livewire and filament all at once 😅
Dan Harrin
Dan Harrin14mo ago
i would learn laravel first so you understand how that works and what benefits filament provides
Damien
DamienOP14mo ago
is the bootcamp enough for laravel would you say I have a rough idea about it, mostly just been thrown in at the deepend haha the livewire docs for full page components don't seem to mentioned storing data. unless I am being blind.
Dan Harrin
Dan Harrin14mo ago
they mention route parameters, right?
Damien
DamienOP14mo ago
yeah, and it does show it for components but my class is a page, unless it is the 'same' with Livewire and actually a component.
Want results from more Discord servers?
Add your server