Passing props to a custom column

I have the following custom column
@props(['title', 'subtitle'])

<div>
    <div class="flex items-center">
        <div class="ml-2.5 truncate flex flex-col text-left">
            <div class="text-sm font-medium truncate text-foreground">
                {{ $title }}
            </div>

            <div class="text-xs truncate text-muted-foreground">
                {{ $subtitle }}
            </div>
        </div>
    </div>
</div>

Is there a way to pass the props from the resource?
MediaObjectColumn::make('avatar_url')
                    ->label('Avatar')
Solution
add in your MediaObjectColumn class

protected string|Closure|null $title = null;

public function title(string|Closure|null $title): static
{
    $this->title = $title;

    return $this;
}

public function getTitle(): ?string
{
    return $this->evaluate($this->title);
}


MediaObjectColumn::make('avatar_url')
    ->label('Avatar')
    ->title('Custom title')


in the view
{{ $getTitle() }}
Was this page helpful?