You can make an Accessor on the Supplier model:
protected function imgPath(): Attribute
{
return Attribute::make(
get: fn (string $value) => "thumbnails/$value",
);
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
In table suppliers I have a column 'img_path'. I like to change each grabbed value from that column to 'thumbnails/'.$suppliers->img_path before I send $suppliers to the view, how can I do that?
The render method:
{
$suppliers = Supplier::query()
->select(['suppliers.*', 'users.name as userName'])
->join('users', 'users.id', '=', 'suppliers.ub');
$suppliers->orderBy($this->sortColumn, $this->sortDirection);
return view('livewire.suppliers.all', [
'suppliers' => $suppliers->paginate(10)
]);
}
You can make an Accessor on the Supplier model:
protected function imgPath(): Attribute
{
return Attribute::make(
get: fn (string $value) => "thumbnails/$value",
);
}
Please or to participate in this conversation.