Skip to content

Commit

Permalink
Update docs (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov authored Aug 25, 2024
1 parent 675deff commit ded355d
Show file tree
Hide file tree
Showing 10 changed files with 482 additions and 49 deletions.
17 changes: 5 additions & 12 deletions docs/create-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,9 @@ use Yiisoft\ActiveRecord\ActiveRecord;
/**
* Entity User.
**/
#[\AllowDynamicProperties]
final class User extends ActiveRecord
{
public int $id;
public string $username;
public string $email;
public int $profile_id;

public function getTableName(): string
{
return '{{%user}}';
}

public function relationQuery(string $name): ActiveQueryInterface
{
return match ($name) {
Expand Down Expand Up @@ -282,14 +273,16 @@ Now you can use `$user->getProfile()` and `$user->getOrders()` to access the rel
```php
use Yiisoft\ActiveRecord\ActiveQuery;

$userQuery = new ActiveQuery(User::class, $db);
$userQuery = new ActiveQuery(User::class);

$user = $userQuery->where(['id' => 1])->one();

$profile = $user->getProfile();
$orders = $user->getOrders();
```

Also see [Using Dependency Injection With Active Record Model](docs/using-di.md).
For more information on defining relations, see [Define Relations](define-relations.md).

Also see [Using Dependency Injection With Active Record Model](using-di.md).

Back to [README](../README.md)
4 changes: 2 additions & 2 deletions docs/define-connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ use Psr\Http\Message\ResponseInterface;
use Yiisoft\ActiveRecord\ConnectionProvider;
use Yiisoft\Db\Connection\ConnectionInterface;

final class Register
final class SomeController
{
public function register(
public function someAction(
ConnectionInterface $db,
): ResponseInterface {
ConnectionProvider::set($db);
Expand Down
Loading

0 comments on commit ded355d

Please sign in to comment.