Resolve the nested resources to an array.

@param  array                     $data
@param  \Illuminate\Http\Request  $request

@return array
349765
protected function resolveNestedRelations($data, $request)
    {
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $data[$key] = $this->resolveNestedRelations($value, $request);
            }
            elseif ($value instanceof static) {
                $data[$key] = $value->resolve($request);
            }
        }

        return $this->filter($data);
    }
458048
public function prepareData(ServerRequest $request): array
    {
        $result = $request->getData();

        $event = new Event((string)EventName::MODEL_SEARCH_CHILD_ITEMS(), $this, [
            'criteria' => $result
        ]);
        EventManager::instance()->dispatch($event);

        $result = $event->result ? $event->result : $result;

        $value = Hash::get($result, 'criteria.query');

        // advanced search
        if (!$value) {
            return $result;
        }

        // basic search query, converted to search criteria
        $result['aggregator'] = 'OR';
        $basicSearch = new BasicSearch($this->table, $this->user);
        $result['criteria'] = $basicSearch->getCriteria($value);

        return $result;
    }
179189
protected function getData(Request $request)
    {
        $data = null;
        if ($request->query->has('dataId')) {
            $data = $this->get(DataRepository::class)->find($request->query->get('dataId'));
        }

        return $data;
    }
325105
private function merge(ServerRequestInterface $request, array $data)
    {
        $existing = $request->getAttribute('viewData', []);
        return array_merge($existing, $data);
    }
850124
protected function extractProperties(Request $request): array
    {
        $needsFixing = false;

        if (null !== $this->properties) {
            foreach ($this->properties as $property => $value) {
                if ($this->isPropertyNested($property) && $request->query->has(str_replace('.', '_', $property))) {
                    $needsFixing = true;
                }
            }
        }

        if ($needsFixing) {
            $request = RequestParser::parseAndDuplicateRequest($request);
        }

        return $request->query->all();
    }
660850
public function get_update_datas(Request $request)
    {
        $datas = [
            'title'       => $request->get('modif_title'),
            'description' => $request->get('modif_description'),
            'tags'        => $request->get('modif_tags'),
            'private'     => $request->get('modif_privacy') === 'private' ? true : false,
        ];

        return $datas;
    }
550518
private function getUriContext(Request $request): array
    {
        $context = $request->query->get('ngbmContext');
        $context = is_array($context) ? $context : [];

        if (!$this->uriSigner->check($this->getUri($request))) {
            return [];
        }

        return $context;
    }
841054
public function solveResolutions(array $data)
    {
        return null !== $this->resolutionManager
            ? $this->resolutionManager->solveResolutions($data)
            : $data;
    }
699441
public function toArray($request)
    {
        /** @var \Unite\Contacts\Models\Contact $this->resource */
        return [
            'id'                => $this->id,
            'type'              => $this->type,
            'name'              => $this->name,
            'surname'           => $this->surname,
            'company'           => $this->company,
            'street'            => $this->street,
            'zip'               => $this->zip,
            'city'              => $this->city,
            'country'           => new CountryResource($this->country),
            'abroad'            => $this->isAbroad(),
            'reg_no'            => $this->reg_no,
            'tax_no'            => $this->tax_no,
            'vat_no'            => $this->vat_no,
            'web'               => $this->web,
            'email'             => $this->email,
            'telephone'         => $this->telephone,
            'description'       => $this->description,
            'custom_properties' => $this->custom_properties,
        ];
    }
263655
protected function resolveUseVariables($data)
    {
        foreach ($data as $key => $value) {
            $data[$key] = $this->getRestoredPropertyValue($value);
        }

        return $data;
    }
490788
public function toArray($request)
    {
        return [
            'id'              => (int) $this->id,
            'author_id'       => $this->author_id,
            'language_code'   => $this->language_code,
            'title'           => $this->title,
            'teaser'          => $this->teaser,
            'body'            => $this->body,
            'seo_title'       => $this->seo_title,
            'seo_description' => $this->seo_description,
            'is_active'       => $this->is_active,
            'created_at'      => dateTimeToRequestTimezone($this->created_at)->toIso8601String(),
            'updated_at'      => dateTimeToRequestTimezone($this->updated_at)->toIso8601String(),
        ];
    }
29288
protected function getObjectDataManager(Request $request)
    {
        $objectDataManager = $this->container->get(ObjectDataManager::class);
        $resolver = new OptionsResolver();
        $resolver->setDefaults([
            "folder" => null,
        ]);
        $resolver->setRequired(["returnUrl","objectId","objectType"]);
        $config = $resolver->resolve($request->get("_conf"));
        $objectDataManager->configure($config["objectId"],$config["objectType"]);
        $objectDataManager->documents()->folder($config["folder"]);
        $this->config = $config;
        return $objectDataManager;
    }
670062
public function toArray($request)
    {
        if (is_null($this->resource)) {
            return [];
        }

        return is_array($this->resource)
            ? $this->resource
            : $this->resource->toArray();
    }
374212
public function get_update_datas(Request $request)
    {
        $datas = [
            'title'       => $request->get('modif_title'),
            'description' => $request->get('modif_description'),
            'category'    => $request->get('modif_category'),
            'tags'        => $request->get('modif_tags'),
            'privacy'     => $request->get('modif_privacy'),
        ];

        return $datas;
    }
2395
private function prepareRequestParams(array $data)
    {
        $has_resource = false;
        $multipart = [];

        foreach ($data as $key => $value) {
            if (!is_array($value)) {
                $multipart[] = ['name' => $key, 'contents' => $value];
                continue;
            }

            foreach ($value as $multiKey => $multiValue) {
                is_resource($multiValue) && $has_resource = true;
                $multiName = $key . '[' . $multiKey . ']' . (is_array($multiValue) ? '[' . key($multiValue) . ']' : '') . '';
                $multipart[] = ['name' => $multiName, 'contents' => (is_array($multiValue) ? reset($multiValue) : $multiValue)];
            }
        }

        if ($has_resource) {
            return ['multipart' => $multipart];
        }

        return ['form_params' => $data];
    }
9312
public function editAction(Request $request, $data = null)
    {
        if (null === $data) {
            $data = $this->getDataFromRequest($request);
        }
        $form = $this->getForm($request, $data);

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $this->saveEntity($data);

            $parameters = $request->query->all();
            $parameters['success'] = 1;

            return $this->redirectToEntity($data, 'edit', $parameters);
        }

        return $this->renderAction($this->getViewParameters($request, $form, $data));
    }
1203402
public function toArray($request)
    {
        return [
            'id' => $this->id,
            'user_id' => $this->user_id,
            'first_name' => $this->first_name,
            'last_name' => $this->last_name,
            'address1' => $this->address1,
            'address2' => $this->address2,
            'postcode' => $this->postcode,
            'city' => $this->city,
            'state' => $this->state,
            'country_name' => $this->country->name,
            'phone' => $this->phone,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
        ];
    }