Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

777not888's avatar

How to change background-color of row on index page of resource?

Depending on the content in the "status" column, the row should be of a certain color. For example, if the 'status' is 'null', then the row is yellow.

0 likes
1 reply
bugsysha's avatar
style="{{ $object->rowColor() }}"


public function rowColor(): string
{
	return $this->rowColorMappings()[$this->status] ?? 'yellow';
}

protected function rowColorMappings(): array
{
	return [
		'status1' => 'color1',
	];
}

Please or to participate in this conversation.