Is it possible to display hasMany relations into the view action?
I have this livewire component..
on this component you see that I set an ViewAction as slideOver.. Is it possible to add all the relations of the item? Lets say that the role has many permissions and I want to list all permissions of that role.
<?php
namespace App\Livewire;
use App\Models\Role;
use App\Services\RolesAndPermissionService;
use Filament\Tables\Actions\EditAction;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Table;
use Livewire\Component;
use Filament\Tables;
use Filament\Forms;
class RolesAndPermissions extends Component implements HasTable, HasForms
{
use InteractsWithTable, InteractsWithForms;
public function render()
{
return view('livewire.roles-and-permissions');
}
public function table(Table $table): Table
{
return $table
->query(Role::query())
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('label'),
])
->actions([
Tables\Actions\ViewAction::make()
->slideOver()
->form(RolesAndPermissionService::schema()),
EditAction::make()
->slideOver()
->form(RolesAndPermissionService::schema()),
Tables\Actions\DeleteAction::make()
])
->headerActions([
Tables\Actions\CreateAction::make()
->slideOver()
->model(Role::class)
->form(RolesAndPermissionService::schema())
]);
}
}
<?php
namespace App\Livewire;
use App\Models\Role;
use App\Services\RolesAndPermissionService;
use Filament\Tables\Actions\EditAction;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Table;
use Livewire\Component;
use Filament\Tables;
use Filament\Forms;
class RolesAndPermissions extends Component implements HasTable, HasForms
{
use InteractsWithTable, InteractsWithForms;
public function render()
{
return view('livewire.roles-and-permissions');
}
public function table(Table $table): Table
{
return $table
->query(Role::query())
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('label'),
])
->actions([
Tables\Actions\ViewAction::make()
->slideOver()
->form(RolesAndPermissionService::schema()),
EditAction::make()
->slideOver()
->form(RolesAndPermissionService::schema()),
Tables\Actions\DeleteAction::make()
])
->headerActions([
Tables\Actions\CreateAction::make()
->slideOver()
->model(Role::class)
->form(RolesAndPermissionService::schema())
]);
}
}
0 Replies