Not be able to show a resource file with same model in different panels.
i have implement two panels in my code
admin
and onwer
.
In the admin panel
i have implemented the user resource file with the user model. which is working fine.
Now i implemented the same thing for my owner panel
but it is not showing in the navigation bar.
```
<?php
namespace App\Filament\Owner\Resources;
use App\Filament\Owner\Resources\UserResource\Pages;
use App\Filament\Owner\Resources\UserResource\RelationManagers;
use App\Models\User;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static ?string $panel = 'owner';
protected static ?string $navigationIcon = 'heroicon-o-users';
protected static ?string $navigationGroup = 'Settings';
protected static ?string $navigationLabel = 'Users';
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery();
}
public static function shouldRegisterNavigation(): bool
{
return true;
}
public static function canViewNavigation(): bool
{
return true;
}
public static function table(Table $table): Table
{
return $table
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getPages(): array
{
return [
'index' => Pages\ListUsers::route('/'),
'create' => Pages\CreateUser::route('/create'),
'edit' => Pages\EditUser::route('/{record}/edit'),
];
}
}
Note: i have removed the unnecessary code due to the text limit.
11 Replies
Do you have more than one UserResource?
yes @awcodes
One in
admin
panel
and one in owner
panel
i tried with a different name too.
By giving a different name to the resource file. But the issue lies with this line of code.
protected static ?string $model = User::class;
If i use some other model name it shows up. But when i add this model .
it don't show up.Hmm, that’s shouldn’t matter. Are the resources any different between panels?
mean?
Are the 2 UserResources doing anything different? Or are they the same.
currently they doing the same thing.
just fetching the data from the users table.
issue is that for the
owner panel
the navigation tab isn't showing
for admin side it is working fineEither the auto discovery is off for the panel that isn’t working or there’s a policy issue. Hard to say without seeing all the code. If you have a repo you can share I’m happy to investigate it further though. But I’m not seeing anything wrong with the code you’ve shared.
i can't share repo. But if there's any specific file you think there can be an issue i can share that file. Hope u understand.
@awcodes this is my user model and owner panel provider files
Ok. Looks like your user depends on tenants but your owner panel doesn’t look like it’s using tenancy. Maybe that’s the issue. That’s the only thing standing out to me. But I’m not 💯 sure.
@awcodes ok. thanks alot for taking your time to answer my query. i'll look into in.