Skip to content

Commit 97bd76a

Browse files
committed
major refactor: rename package to laravel snap
1 parent 1bebc7c commit 97bd76a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+186
-185
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Laravel Complete Model Snapshot
1+
# Laravel Snap
22

33
> [!CAUTION]
44
> This package is currently in early stages of active development and should not be used in production environments.
@@ -21,20 +21,20 @@ essential.
2121
## Installation
2222
### 1. Install the package:
2323
```bash
24-
composer require dvarilek/laravel-complete-model-snapshot
24+
composer require dvarilek/laravel-snap
2525
```
2626
### 2. Initialize the package
2727
```bash
28-
php artisan complete-model-snapshot:install
28+
php artisan laravel-snap:install
2929
```
3030
***
3131
## Basic Usage & Configuration
3232

3333
Firstly, we need to make our Eloquent model snapshotable and configure what should and shouldn't get captured in our snapshot.
34-
Start by using the Snapshotable trait in your Model:
34+
The configuration happens through a SnapshotDefinition. Start by using the Snapshotable trait in your Model:
3535
```php
36-
use Dvarilek\CompleteModelSnapshot\Models\Concerns\Snapshotable;
37-
use Dvarilek\CompleteModelSnapshot\ValueObjects\SnapshotDefinition;
36+
use Dvarilek\LaravelSnap\Models\Concerns\Snapshotable;
37+
use Dvarilek\LaravelSnap\ValueObjects\SnapshotDefinition;
3838

3939
class MyModel extends Model
4040
{
@@ -106,7 +106,7 @@ SnapshotDefinition::make()
106106
107107
You can customize the timestamp prefix ('origin_') by publishing and modifying the package's configuration file:
108108
```bash
109-
php artisan vendor:publish --tag=complete-model-snapshot-config
109+
php artisan vendor:publish --tag=laravel-snap-config
110110
```
111111

112112
### Capturing Related Attributes
@@ -116,7 +116,7 @@ being prefixed by their relation path relative to the main model. This is done t
116116

117117
To capture related attributes you need to provide a RelationDefinition(s):
118118
```php
119-
use Dvarilek\CompleteModelSnapshot\ValueObjects\{SnapshotDefinition, RelationDefinition}
119+
use Dvarilek\LaravelSnap\ValueObjects\{SnapshotDefinition, RelationDefinition}
120120

121121
SnapshotDefinition::make()
122122
->captureRelations([
@@ -149,7 +149,7 @@ SnapshotDefinition::make()
149149
For deeply nested related attributes the same prefix rules apply. You can capture them
150150
by capturing them like this:
151151
```php
152-
use Dvarilek\CompleteModelSnapshot\ValueObjects\{SnapshotDefinition, RelationDefinition}
152+
use Dvarilek\LaravelSnap\ValueObjects\{SnapshotDefinition, RelationDefinition}
153153

154154
SnapshotDefinition::make()
155155
->captureRelations([
@@ -180,7 +180,7 @@ SnapshotDefinition::make()
180180
A single model can have multiple snapshots. To create new snapshot call the takeSnapshot method on your Snapshotable model.
181181

182182
```php
183-
use Dvarilek\CompleteModelSnapshot\Models\Snapshot;
183+
use Dvarilek\LaravelSnap\Models\Snapshot;
184184
use Illuminate\Database\Eloquent\Model;
185185

186186
/** @var Snapshot&Model $snapshot */
@@ -247,7 +247,7 @@ Since snapshot attributes are stored in a json column, they can't be queried dir
247247
the JSON column. For more information about JSON querying see the [**Official Laravel Documentation**](https://laravel.com/docs/10.x/queries#json-where-clauses)
248248

249249
```php
250-
use Dvarilek\CompleteModelSnapshot\Models\Snapshot;
250+
use Dvarilek\LaravelSnap\Models\Snapshot;
251251

252252
// For captured attribute by the name 'custodian_name'
253253
Snapshot::query()->where('storage->custodian_name->value', $value);
@@ -281,8 +281,8 @@ $model = $model->latestSnapshot->sync();
281281
While working with snapshots, you can hook into the snapshotting and rewinding processes.
282282

283283
```php
284-
use Dvarilek\CompleteModelSnapshot\Models\Concerns\Snapshotable;
285-
use Dvarilek\CompleteModelSnapshot\ValueObjects\SnapshotDefinition;
284+
use Dvarilek\LaravelSnap\Models\Concerns\Snapshotable;
285+
use Dvarilek\LaravelSnap\ValueObjects\SnapshotDefinition;
286286

287287
class MyModel extends Model
288288
{
@@ -377,7 +377,7 @@ Internally, all snapshot attribute sare set using special DTO's. These DTO's can
377377
with extra metadata e.g. setting/changing casts etc.
378378

379379
```php
380-
use Dvarilek\CompleteModelSnapshot\DTO\{AttributeTransferObject, RelatedAttributeTransferObject}
380+
use Dvarilek\LaravelSnap\DTO\{AttributeTransferObject, RelatedAttributeTransferObject}
381381
use Illuminate\Database\Eloquent\Casts\{AsStringable, AsCollection};
382382

383383
$snapshot->update([
@@ -416,7 +416,7 @@ composer test && composer stan
416416
```
417417

418418
## Changelog
419-
Please refer to [Package Releases](https://github.com/dvarilek/laravel-complete-model-snapshot/releases) for more information about changes.
419+
Please refer to [Package Releases](https://github.com/dvarilek/laravel-snap/releases) for more information about changes.
420420

421421
## License
422422
This package is under the MIT License. Please refer to [License File](LICENSE.md) for more information

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "dvarilek/laravel-complete-model-snapshot",
2+
"name": "dvarilek/laravel-snap",
33
"description": "A Laravel package for capturing and persisting the state of Eloquent models along with their relationships.",
44
"keywords": [
55
"laravel",
@@ -11,12 +11,12 @@
1111
"license": "MIT",
1212
"autoload": {
1313
"psr-4": {
14-
"Dvarilek\\CompleteModelSnapshot\\": "src"
14+
"Dvarilek\\LaravelSnap\\": "src"
1515
}
1616
},
1717
"autoload-dev": {
1818
"psr-4": {
19-
"Dvarilek\\CompleteModelSnapshot\\Tests\\": "tests/"
19+
"Dvarilek\\LaravelSnap\\Tests\\": "tests/"
2020
}
2121
},
2222
"authors": [
@@ -41,7 +41,7 @@
4141
"extra": {
4242
"laravel": {
4343
"providers": [
44-
"Dvarilek\\CompleteModelSnapshot\\LaravelCompleteModelSnapshotServiceProvider"
44+
"Dvarilek\\LaravelSnap\\LaravelSnapServiceProvider"
4545
]
4646
}
4747
},
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<?php
22

3-
// Configuration file for Complete Model Snapshot Package
3+
// Configuration file for Laravel Snap package
44

5-
use Dvarilek\CompleteModelSnapshot\Models\Snapshot;
5+
use Dvarilek\LaravelSnap\Models\Snapshot;
66

77
return [
88

99
/**
1010
* Configuration for the polymorphic relationships between your models and their snapshots.
1111
*
1212
* model - The Snapshot model class to use for storing model snapshots
13-
* - must implement @see \Dvarilek\CompleteModelSnapshot\Models\Contracts\SnapshotContract
13+
* - must implement @see \Dvarilek\LaravelSnap\Models\Contracts\SnapshotContract
1414
* morph-name - The base name used for polymorphic relations
1515
* morph-type - The database column storing the parent model's class name
1616
* morph-id - The database column storing the parent model's ID
1717
* local-key - The primary key of your models (typically 'id')
1818
*
19-
* @see \Dvarilek\CompleteModelSnapshot\Models\Concerns\Snapshotable trait for implementation details
19+
* @see \Dvarilek\LaravelSnap\Models\Concerns\Snapshotable trait for implementation details
2020
*/
2121
'snapshot-model' => [
2222

src/DTO/AttributeTransferObject.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace Dvarilek\CompleteModelSnapshot\DTO;
5+
namespace Dvarilek\LaravelSnap\DTO;
66

7-
use Dvarilek\CompleteModelSnapshot\DTO\Contracts\VirtualAttribute;
7+
use Dvarilek\LaravelSnap\DTO\Contracts\VirtualAttribute;
88

99
final readonly class AttributeTransferObject implements VirtualAttribute
1010
{

src/DTO/Contracts/VirtualAttribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Dvarilek\CompleteModelSnapshot\DTO\Contracts;
5+
namespace Dvarilek\LaravelSnap\DTO\Contracts;
66

77
use Illuminate\Contracts\Support\Arrayable;
88

src/DTO/RelatedAttributeTransferObject.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace Dvarilek\CompleteModelSnapshot\DTO;
5+
namespace Dvarilek\LaravelSnap\DTO;
66

7-
use Dvarilek\CompleteModelSnapshot\DTO\Contracts\VirtualAttribute;
7+
use Dvarilek\LaravelSnap\DTO\Contracts\VirtualAttribute;
88

99
final readonly class RelatedAttributeTransferObject implements VirtualAttribute
1010
{

src/Exceptions/InvalidConfigurationException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace Dvarilek\CompleteModelSnapshot\Exceptions;
5+
namespace Dvarilek\LaravelSnap\Exceptions;
66

7-
use Dvarilek\CompleteModelSnapshot\Models\Contracts\SnapshotContract;
7+
use Dvarilek\LaravelSnap\Models\Contracts\SnapshotContract;
88
use Illuminate\Database\Eloquent\Model;
99

1010
final class InvalidConfigurationException extends \Exception

src/Exceptions/InvalidRelationException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace Dvarilek\CompleteModelSnapshot\Exceptions;
5+
namespace Dvarilek\LaravelSnap\Exceptions;
66

7-
use Dvarilek\CompleteModelSnapshot\Support\RelationValidator;
7+
use Dvarilek\LaravelSnap\Support\RelationValidator;
88
use Illuminate\Database\Eloquent\Model;
99

1010
final class InvalidRelationException extends \Exception

src/Exceptions/InvalidSnapshotException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
declare(strict_types=1);
44

5-
namespace Dvarilek\CompleteModelSnapshot\Exceptions;
5+
namespace Dvarilek\LaravelSnap\Exceptions;
66

7-
use Dvarilek\CompleteModelSnapshot\DTO\AttributeTransferObject;
8-
use Dvarilek\CompleteModelSnapshot\DTO\RelatedAttributeTransferObject;
9-
use Dvarilek\CompleteModelSnapshot\Models\Contracts\SnapshotContract;
7+
use Dvarilek\LaravelSnap\DTO\AttributeTransferObject;
8+
use Dvarilek\LaravelSnap\DTO\RelatedAttributeTransferObject;
9+
use Dvarilek\LaravelSnap\Models\Contracts\SnapshotContract;
1010
use Illuminate\Database\Eloquent\Model;
1111

1212
final class InvalidSnapshotException extends \InvalidArgumentException

src/Helpers/ModelHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Dvarilek\CompleteModelSnapshot\Helpers;
5+
namespace Dvarilek\LaravelSnap\Helpers;
66

77
use Illuminate\Database\Eloquent\Model;
88
use Illuminate\Database\Eloquent\SoftDeletes;

0 commit comments

Comments
 (0)