0

I have a problem with my Laravel filaments Relation in the "backend" interface. The column with my Relation isn't shown.

I have a simple model with a Profilisocial and Users. The edit is working and updating the Database as expected, but I cannot get it to list it on index page of the Filament backend.

I have following in my ProfilisocialResource.php

According to documentation for filamentphp version 3.x, this should be how it done: https://filamentphp.com/docs/3.x/tables/columns/relationships#displaying-data-from-relationships it's the same code for filamentphp version 2.x https://filamentphp.com/docs/2.x/tables/columns/relationships

    public static function table(Table $table): Table
{
    return $table
        ->columns([
            TextColumn::make('id')->sortable(),
            TextColumn::make('myusers.email'), <--- HERE THE NOT WORKING CODE
        ])
        ->filters([
            //
        ])
        ->actions([
            Tables\Actions\EditAction::make(),
        ])
        ->bulkActions([
            Tables\Actions\DeleteBulkAction::make(),
        ]);
}

my Profilisocial.php model has the relation:

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Profilisocial extends Model
{
    public $table = 'profilisocial';
    use HasFactory;
    protected $fillable = [
        'id',
        'facebook',
        'twitter',
        'linkedin',
        'users_ID',
        'created_at',
        'updated_at',
    ];

    public function myusers(): BelongsTo{
        return $this->belongsTo(User::class);
    }
}

but the email is not displayed as you can see in the screenshot, why? can anybody help me please? enter image description here

user626920
  • 35
  • 1
  • 6
  • instead of
    TextColumn::make('myusers.email') i also try
    TextColumn::make('myusers.last_name') but without success in my database, the table users has both column email and last_name populated There are not errors in my laravel lof file
    – user626920 Aug 23 '23 at 07:34

0 Answers0