Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function extraFields()
 {
     $fields = parent::extraFields();
     ApiAttribute::datetimeFormat($fields, 'created_at');
     ApiAttribute::datetimeFormat($fields, 'updated_at');
     return $fields;
 }
Beispiel #2
0
 /**
  * @inheritdoc
  */
 public function extraFields()
 {
     $fields = parent::extraFields();
     $fields['meta'] = function (Model $Model) {
         return $Model->meta();
     };
     $fields['picture_300'] = function (Model $Model) {
         $result = null;
         $Media = $Model->pictureMedia;
         if (!empty($Media)) {
             $result = $Media->image()->resizeByWidth(300)->export();
         }
         return $result;
     };
     $fields['sections'] = function (Model $Model) {
         $result = [];
         $item_sections = $Model->getItemSections()->asArray()->all();
         if (!empty($item_sections)) {
             $result = ArrayHelper::getColumn($item_sections, 'section_id');
             $result = array_map('intval', $result);
         }
         return $result;
     };
     ApiAttribute::datetimeFormat($fields, 'created_at');
     ApiAttribute::datetimeFormat($fields, 'updated_at');
     ApiAttribute::datetimeFormat($fields, 'published_at');
     ApiAttribute::datetimeFormat($fields, 'archived_at');
     ApiAttribute::datetimeFormat($fields, 'deleted_at');
     ApiAttribute::datetimeFormat($fields, 'activated_at');
     return $fields;
 }
Beispiel #3
0
 /**
  * @inheritdoc
  */
 public function extraFields()
 {
     $fields = parent::extraFields();
     $fields['roles'] = function (Model $Model) {
         $result = [];
         $roles = AuthManager()->getRolesByUser($Model->id);
         foreach ($roles as $role => $conf) {
             $result[$role] = true;
         }
         return $result;
     };
     $fields['permissions'] = function (Model $Model) {
         $result = [];
         $permissions = AuthManager()->getPermissionsByUser($Model->id);
         foreach ($permissions as $permission => $conf) {
             $result[$permission] = true;
         }
         return $result;
     };
     $fields['properties'] = function (Model $Model) {
         return $Model->properties();
     };
     $fields['alerts'] = function (Model $Model) {
         $Alerts = $this->alerts;
         return empty($Alerts) ? [] : ArrayHelper::getColumn($Alerts, function (AccountAlertModel $Model) {
             return $Model->toArray();
         });
     };
     ApiAttribute::datetimeFormat($fields, 'created_at');
     ApiAttribute::datetimeFormat($fields, 'updated_at');
     ApiAttribute::datetimeFormat($fields, 'activated_at');
     ApiAttribute::datetimeFormat($fields, 'deleted_at');
     return $fields;
 }
Beispiel #4
0
 /**
  * @inheritdoc
  */
 public function extraFields()
 {
     $fields = parent::extraFields();
     $fields['account'] = function (Model $Model) {
         $result = null;
         $Account = $Model->account;
         if (!empty($Account)) {
             $result = $Account->toArray();
         }
         return $result;
     };
     $fields['properties'] = function (Model $Model) {
         $result = [];
         $properties = $Model->properties();
         if (!empty($properties)) {
             foreach ($properties as $key => $values) {
                 $result[$key] = $values;
             }
         }
         return $result;
     };
     ApiAttribute::datetimeFormat($fields, 'created_at');
     ApiAttribute::datetimeFormat($fields, 'updated_at');
     ApiAttribute::datetimeFormat($fields, 'deleted_at');
     return $fields;
 }
Beispiel #5
0
 /**
  * @inheritdoc
  */
 public function extraFields()
 {
     $fields = parent::extraFields();
     $fields['meta'] = function (Model $Model) {
         return $Model->meta();
     };
     ApiAttribute::datetimeFormat($fields, 'created_at');
     ApiAttribute::datetimeFormat($fields, 'updated_at');
     ApiAttribute::datetimeFormat($fields, 'activated_at');
     ApiAttribute::datetimeFormat($fields, 'deleted_at');
     return $fields;
 }