Passing props to a custom column
I have the following custom column
Is there a way to pass the props from the resource?
@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>@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')MediaObjectColumn::make('avatar_url')
->label('Avatar')Solution
add in your MediaObjectColumn class
in the view
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);
}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')MediaObjectColumn::make('avatar_url')
->label('Avatar')
->title('Custom title')in the view
{{ $getTitle() }}{{ $getTitle() }}