Displaying a flag based on value based on multiple columns #735
-
In a list I would like to display a svg image showing if the record has been tempered with or not. For this reason I have a hash value stored in the database. I need to compare the hash value in the database with the one generated for the data. If they match than I want to display a particular svg image, and if they do not match I want to display another svg image. My idea was to use a custom column but have stumbled upon a block - one table my have 3 columns, another may have 10 columns whilst another may have 7 columns and do not want to create a custom column for each screen that I have to perform the same function Could do with placing everything in an array and than go through the array in the function but do not know how I can get the data (all columns values) in an array and passed to the function evaluated there and the right svg image displayed Any suggestion is welcome |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hmm... I would probably use the CRUD::column('name')->value(function($entry) {
if ($entry->isTampered('name') {
return '<img src="red.png">' . $name;
}
return '<img src="green.png">' . $name;
})->escaped(false); Now that I write it though... I don't particularly love it. Another option would be to create ONE custom column ( CRUD::column('name')->type('text_with_tampered_icon'); So then my actual answer is... I'd do that on the model 😀 I would have a function on the model that just returns true/false if a particular column was tampered with, and use that in my admin panel / wherever else. Hope it helps. |
Beta Was this translation helpful? Give feedback.
I got what I need and I am sharing so that I learn if it can be improved
this is my column definition
in model