Skip to content
This repository was archived by the owner on Dec 10, 2018. It is now read-only.

Commit ed1a38e

Browse files
committed
Deprecate the HasUuidPrimaryKey
1 parent cf4540a commit ed1a38e

File tree

5 files changed

+26
-23
lines changed

5 files changed

+26
-23
lines changed

CHANGELOG.md

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

33
All notable changes to `laravel-binary-uuid` will be documented in this file
44

5+
## 1.1.5 - 2018-02-12
6+
7+
- Better support for route binding #36.
8+
- Deprecate the `HasUuidPrimaryKey` trait, as its functionality is moved to `HasBinaryUuid`.
9+
510
## 1.1.4 - 2018-02-08
611

712
- Support Laravel 5.6

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,15 @@ Schema::create('table_name', function (Blueprint $table) {
3636
});
3737
```
3838

39-
If you want to use uuid as a primary key you must let your model use the `HasBinaryUuid` and the `HasUuidPrimaryKey` traits.
39+
To get your model to work with the encoded UUID, use the `Spatie\BinaryUuid\HasBinaryUuid` trait in your model.
4040

4141
```php
4242
use Illuminate\Database\Eloquent\Model;
4343
use Spatie\BinaryUuid\HasBinaryUuid;
44-
use Spatie\BinaryUuid\HasUuidPrimaryKey;
4544

4645
class TestModel extends Model
4746
{
48-
use HasBinaryUuid,
49-
HasUuidPrimaryKey;
47+
use HasBinaryUuid;
5048
}
5149
```
5250

@@ -58,8 +56,7 @@ use Spatie\BinaryUuid\HasBinaryUuid;
5856

5957
class TestModel extends Model
6058
{
61-
use HasBinaryUuid,
62-
HasUuidPrimaryKey;
59+
use HasBinaryUuid;
6360

6461
public function getKeyName()
6562
{
@@ -83,7 +80,6 @@ To make those work, you'll have to change the migration of those notifications t
8380
$table->char('id', 36)->primary();
8481
```
8582

86-
8783
### Creating a model
8884

8985
The UUID of a model will automatically be generated upon save.

src/HasBinaryUuid.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,19 @@ public function getRouteKeyName()
100100
{
101101
return 'uuid_text';
102102
}
103+
104+
public function getKeyName()
105+
{
106+
return 'uuid';
107+
}
108+
109+
public function getIncrementing()
110+
{
111+
return false;
112+
}
113+
114+
public function resolveRouteBinding($value)
115+
{
116+
return $this->withUuid($value)->first();
117+
}
103118
}

src/HasUuidPrimaryKey.php

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

33
namespace Spatie\BinaryUuid;
44

5+
/**
6+
* @deprecated The logic of this trait is moved to `Spatie\BinaryUuid\HasBinaryUuid` and this trait will be removed with the next major version.
7+
*/
58
trait HasUuidPrimaryKey
69
{
7-
public function getKeyName()
8-
{
9-
return 'uuid';
10-
}
11-
12-
public function getIncrementing()
13-
{
14-
return false;
15-
}
16-
17-
public function resolveRouteBinding($value)
18-
{
19-
return $this->withUuid($value)->first();
20-
}
2110
}

tests/TestModel.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
use Spatie\BinaryUuid\HasBinaryUuid;
66
use Illuminate\Database\Eloquent\Model;
7-
use Spatie\BinaryUuid\HasUuidPrimaryKey;
87

98
class TestModel extends Model
109
{
1110
use HasBinaryUuid;
12-
use HasUuidPrimaryKey;
1311

1412
protected $table = 'test';
1513
}

0 commit comments

Comments
 (0)