Skip to content
On this page

Users

You may want to create an Authenticable and Authorizable user, like the one shipping by default with Laravel.

Issuing a password or rememberToken as columns will instruct Larawiz to change the type of the model to a User.

yaml
models:

  Admin:
    name: string unique
    password: string
    rememberToken: ~
    age: unsignedSmallInteger default:18
1
2
3
4
5
6
7
php
<?php

namespace App\Models;

use Illuminate\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class Admin extends Authenticatable
{
    use Notifiable;
    use HasFactory;
    
    // ...
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

Forcing a User model

You can force Larawiz to make a model as a User by setting the type key to user, which is useful if you want an User to authenticate without passwords or remember tokens.

yaml
models:

  Kid:
    name: string unique
    age: unsignedSmallInteger default:18
    
    type: user 
1
2
3
4
5
6
7
php
<?php

namespace App\Models;

use Illuminate\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class Kid extends Authenticatable
{
    use Notifiable;
    use HasFactory;
    
    // ...
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

No user model

You can force Larawiz to not change the type of the model to a User by setting the type key to model.

yaml
models:

  Admin:
    name: string unique
    password: string
    rememberToken: ~
    age: unsignedSmallInteger default:18

    type: model
1
2
3
4
5
6
7
8
9
php
class Admin extends Model
{
    // ...
}
1
2
3
4