fill example

$publicParams      = array_intersect_key($params$publicProperties);

        foreach ($params as $key => $value) {
            $getter = 'get' . ucfirst($key) . 'Property';
            if (in_array($key$privateProperties, true) && method_exists($instance$getter)) {
                $publicParams[$key] = $value;
            }
        }

        // Fill in any public properties that were passed in         // but only ones that are in the $pulibcProperties array.         $instance = $instance->fill($publicParams);

        // If there are any protected/private properties, we need to         // send them to the mount() method.         if (method_exists($instance, 'mount')) {
            // if any $params have keys that match the name of an argument in the             // mount method, pass those variables to the method.             $mountParams = $this->getMethodParams($instance, 'mount', $params);
            $instance->mount(...$mountParams);
        }

        return $instance->{$method}();
    }
return $result;
            }
        }

        // Get the array values and apply them to the object         $array  = $this->makeArray();
        $object = new $className();

        // Check for the entity method         if (method_exists($object, 'fill')) {
            $object->fill($array);
        } else {
            foreach ($array as $key => $value) {
                $object->{$key} = $value;
            }
        }

        return $object;
    }

    /** * Generate new entities from the database * * @param int|null $count Optional number to create a collection * @param bool $mock Whether to execute or mock the insertion * * @return array|object An array or object (based on returnType), or an array of returnTypes * * @throws FrameworkException */
$grouped = [];
        foreach ($data as $entity) {
            $fk = $entity->get($propertyName);

            $grouped[$fk][] = $entity;
        }

        // assign loaded data to root entities         foreach ($collection as $entity) {
            $structData = new $collectionClass();
            if (isset($grouped[$entity->getUniqueIdentifier()])) {
                $structData->fill($grouped[$entity->getUniqueIdentifier()]);
            }

            // assign data of child immediately             if ($association->is(Extension::class)) {
                $entity->addExtension($association->getPropertyName()$structData);
            } else {
                // otherwise the data will be assigned directly as properties                 $entity->assign([$association->getPropertyName() => $structData]);
            }

            if (!$association->is(Inherited::class) || $structData->count() > 0 || !$context->considerInheritance()) {
                

    private bool $_cast = true;

    /** * Allows filling in Entity parameters during construction. */
    public function __construct(?array $data = null)
    {
        $this->syncOriginal();

        $this->fill($data);
    }

    /** * Takes an array of key/value pairs and sets them as class * properties, using any `setCamelCasedProperty()` methods * that may or may not exist. * * @param array<string, array|bool|float|int|object|string|null> $data * * @return $this */
    
Home | Imprint | This part of the site doesn't use cookies.