# Record

`Record` presents a single row in your database.

```php

namespace Vendor\Domain\Record;

use Pckg\Database\Record;
use Vendor\Domain\Entity\Users;

class User extends Record
{
    protected $entity = Users::class;
}
```

## Relations

Relations are fetched from the `$entity`.

```php
// ...
class Users extends Entity
{
    // ...
    public function userGroup()
    {
        return $this->belongsTo(UserGroups::class)
            ->foreignKey('user_group_id');
    }
}
```

However, it is recommended that you also define them in your DocBlock so you can enjoy in auto-complete.

```php
// ...
/**
 * @property UserGroup $userGroup
 */
class User extends Record
{
    // ...
}
```

```php
$userGroupId = $user->userGroup->id;
$userGroupUsersCollection = $user->userGroup->users;
```
