Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1.     /**
  2.      * Method removes excluded by user fields from the body.
  3.      *
  4.      * @param string $key
  5.      * @param bool $isUpdate
  6.      * @return array
  7.      */
  8.     public function getBodyFor(string $key, bool $isUpdate = false): array
  9.     {
  10.         if ($isUpdate) {
  11.             foreach ($this->{$key} as $column => $value) {
  12.                 $excluding = $this->config->{'updateExcluding' . ucfirst($key) . 's'};
  13.                 $excludeAll = $this->config->{'updateExcluding' . ucfirst($key) . 'sAll'};
  14.  
  15.                 if (in_array($column, $excluding) || $excludeAll) {
  16.                     unset($this->{$key}[$column]);
  17.                 }
  18.             }
  19.         }
  20.  
  21.         return array_filter($this->{$key} ?? []);
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement