芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/qrafiqxcreativeagency.com/accounts/office/app/Models/CustomFieldGroup.php
'Client', 'model' => ClientDetails::CUSTOM_FIELD_MODEL], ['name' => 'Employee', 'model' => EmployeeDetails::CUSTOM_FIELD_MODEL], ['name' => 'Project', 'model' => Project::CUSTOM_FIELD_MODEL], ['name' => 'Invoice', 'model' => Invoice::CUSTOM_FIELD_MODEL], ['name' => 'Estimate', 'model' => Estimate::CUSTOM_FIELD_MODEL], ['name' => 'Task', 'model' => Task::CUSTOM_FIELD_MODEL], ['name' => 'Expense', 'model' => Expense::CUSTOM_FIELD_MODEL], ['name' => 'Lead', 'model' => Lead::CUSTOM_FIELD_MODEL], ['name' => 'Product', 'model' => Product::CUSTOM_FIELD_MODEL], ['name' => 'Ticket', 'model' => Ticket::CUSTOM_FIELD_MODEL], ['name' => 'Time Log', 'model' => ProjectTimeLog::CUSTOM_FIELD_MODEL], ['name' => 'Contract', 'model' => Contract::CUSTOM_FIELD_MODEL] ]; public $timestamps = false; public function customField(): HasMany { return $this->HasMany(CustomField::class); } public static function customFieldsDataMerge($model) { $customFields = CustomField::exportCustomFields($model); $customFieldsDataMerge = []; foreach ($customFields as $customField) { $customFieldsData = [ $customField->name => [ 'data' => $customField->name, 'name' => $customField->name, 'title' => $customField->label, 'visible' => $customField['visible'], 'orderable' => false, ] ]; $customFieldsDataMerge = array_merge($customFieldsDataMerge, $customFieldsData); } return $customFieldsDataMerge; } /** * Get the custom field group's name. */ protected function fields(): Attribute { return Attribute::make( get: function () { return $this->customField->map(function ($item) { if (in_array($item->type, ['select', 'radio'])) { $item->values = json_decode($item->values); return $item; } return $item; }); }, ); } }