$site->update()
Updates the model data
$site->update(array|null $input = null, string|null $languageCode = null, bool $validate = false): Site
Parameters
| Name | Type | Default |
|---|---|---|
| $input | array<string, mixed>ornull |
null
|
| $languageCode | stringornull |
null
|
| $validate | bool |
false
|
Return type
This method does not modify the existing $site object but returns a new object with the changes applied. Learn more →
Exceptions
| Type | Description |
|---|---|
Kirby\Exception\InvalidArgumentException |
If the input array contains invalid values |
Parent class
Kirby\Cms\Site
inherited from Kirby\Cms\ModelWithContent
Examples
try {
$site->update([
'title' => 'My Site',
'description' => 'it is really nice',
]);
echo 'The site info has been updated';
} catch(Exception $e) {
echo $e->getMessage();
}
Objects as values
Each field of the site's blueprint converts Kirby objects and collections into the format it stores:
$site->update([
'logo' => $site->image('logo.svg'),
'featured' => $site->children()->listed()->limit(3),
'editors' => $kirby->users()->role('editor'),
'launch' => new DateTime(),
]);