Skip to content

Commit

Permalink
1.8 version add
Browse files Browse the repository at this point in the history
  • Loading branch information
akbarali1 committed Mar 27, 2024
1 parent ab19411 commit 314fce6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,10 @@ public function edit(string $type, int $id): View
$viewModel = OrganizationViewModel::createEmpty();

return $viewModel->toView('organization.store');
```

# 1.8 version add `fromDataObject` method

```php
$viewModel = OrganizationViewModel::fromDataObject($orgData);
```
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name":"akbarali/view-model",
"version":"1.7",
"version":"1.8",
"description":"View Model PHP Laravel",
"license":"MIT",
"minimum-stability": "stable",
Expand Down
5 changes: 5 additions & 0 deletions src/BaseViewModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,9 @@ public static function createEmpty(): static
{
return new static(new EmptyData());
}

public static function fromDataObject(DataObjectBase $data): static
{
return new static($data);
}
}

0 comments on commit 314fce6

Please sign in to comment.