Skip to content

Commit

Permalink
docs: improve complex example in the readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
WatheqAlshowaiter committed Jul 14, 2024
1 parent d093a0a commit 444af5b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,24 @@ let's say the `Post` model has these fields
```php
Schema::create('posts', function (Blueprint $table) {
$table->uuid('id')->primary(); // primary key
$table->foreignUlid('user')->constrained(); // required
$table->foreignId('category')->nullable()->constrained(); // nullable
$table->uuid(); // required
$table->ulid()->nullable(); // nullable
$table->foreignId('user_id')->constrained(); // required
$table->foreignId('category')->nullable(); // nullable
$table->uuid(); // required (but will be changed later) 👇
$table->ulid()->nullable(); // nullable (but will be changed later) 👇
$table->boolean('active')->default(false); // default
$table->string('title'); // required
$table->json('description')->nullable();
$table->json('description')->nullable(); // nullable (but will be changed later) 👇
$table->string('slug')->nullable()->unique(); // nullable
$table->timestamps(); // nullable
$table->softDeletes(); // nullable
});

// later migration..
Schema::table('posts', function(Blueprint $table){
$table->json('description')->change(); // required
$table->ulid()->change(); // required
$table->uuid()->nullable()->change(); // nullable
});
```

- We can add the `RequiredFields` trait to the `Post` Model
Expand All @@ -86,7 +93,7 @@ class Post extends Model
- Now use the trait as follows

```php
Post::requiredFields(); // returns ['user', 'uuid', 'title]
Post::requiredFields(); // returns ['user_id', 'ulid', 'title', 'description']
```

## Why?
Expand Down
10 changes: 10 additions & 0 deletions todos.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@
- [x] use phpunit instead of pest
- [ ] test code for SQL server
- [ ] try previous versions of laravel until laravel 6
- [x] 11
- [ ] 10
- [ ] 9
- [ ] 8
- [ ] 7
- [ ] 6
- [ ] try previous versions of php until php 7.4
- [ ] 8.2
- [ ] 8.1
- [ ] 8.0
- [ ] 7.4
- [ ] add GitHub action for all supported SQL databases
- [ ] add GitHub action for all supported laravel versions
- [ ] add GitHub action for all supported php versions

0 comments on commit 444af5b

Please sign in to comment.