Relation Manager and filter

In my relation manager table I want to show users who belong to horses. How can I filter that in relation manager.
Schema::create('horses', function (Blueprint $table) {
$table->id();
$table
->foreignId('user_id')
->constrained()
->cascadeOnDelete();
$table
->foreignId('owner_id')
->constrained('users', 'id')
->cascadeOnDelete();
//
Schema::create('horses', function (Blueprint $table) {
$table->id();
$table
->foreignId('user_id')
->constrained()
->cascadeOnDelete();
$table
->foreignId('owner_id')
->constrained('users', 'id')
->cascadeOnDelete();
//
3 Replies
Shaung Bhone
Shaung BhoneOP2y ago
<?php

namespace App\Filament\Resources\UserResource\RelationManagers;

use Filament\Resources\RelationManagers\RelationManager;
use Filament\Resources\Table;
use Filament\Tables;

class HorsesRelationManager extends RelationManager
{
protected static string $relationship = 'horses';

protected static ?string $recordTitleAttribute = 'owners';

public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('owner_id'),
Tables\Columns\TextColumn::make('name'),
]);
}
}
<?php

namespace App\Filament\Resources\UserResource\RelationManagers;

use Filament\Resources\RelationManagers\RelationManager;
use Filament\Resources\Table;
use Filament\Tables;

class HorsesRelationManager extends RelationManager
{
protected static string $relationship = 'horses';

protected static ?string $recordTitleAttribute = 'owners';

public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('owner_id'),
Tables\Columns\TextColumn::make('name'),
]);
}
}
Cybrarist
Cybrarist2y ago
can you paste the relationship in the models
Shaung Bhone
Shaung BhoneOP2y ago
nevermind I got it now
Want results from more Discord servers?
Add your server