class Composed extends Hidden
{
- protected string $_attribute = '';
+ protected string $_composed = '';
public function getDefaultAttributes()
{
- return array_merge(parent::getDefaultAttributes(), ['attribute' => $this->_attribute]);
+ return array_merge(parent::getDefaultAttributes(), ['composed' => $this->_composed]);
+ }
+
+ public function filterValue($value)
+ {
+ $c = $this->getAttribute('composed');
+ return $this->getModelInstance()->$c();
}
}
use Backpack\CRUD\app\Http\Controllers\Operations\BulkCloneOperation;
use Backpack\CRUD\app\Http\Controllers\Operations\BulkDeleteOperation;
use Backpack\CRUD\app\Http\Controllers\Operations\CloneOperation;
+use Cubist\Backpack\Magic\Fields\Composed;
use Cubist\Backpack\Magic\Fields\Datetime;
use Cubist\Backpack\Magic\Fields\Files;
use Cubist\Backpack\Magic\Operations\CreateOperation;
}
/**
- * @return stringx
+ * @return string
*/
protected function _getBaseController()
{
return $saved;
}
+
+ public static function refreshComposedAttributes(){
+ $all=static::all();
+ foreach ($all as $instance) {
+ foreach ($instance->getFields() as $field) {
+ if($field instanceof Composed){
+ $instance->getAttribute($field->getName());
+ }
+ }
+ $instance->save();
+ }
+ }
}