Hi,
Of course you can, but I'm not sure which part of my code you would like to see but here is my model:
<?php namespace Codebugs\Auth\Models;
use Model;
use Codebugs\Master\Models\Site;
/**
* User Model
*/
class User extends Model
{
use \October\Rain\Database\Traits\Validation;
use \October\Rain\Database\Traits\Hashable;
/**
* @var string The database table used by the model.
*/
public $table = 'codebugs_auth_users';
/**
* @var array Guarded fields
*/
protected $guarded = ['*'];
/**
* @var array Fillable fields
*/
protected $fillable = [];
/**
* @var array Hashable fields
*/
protected $hashable = ['password'];
/**
* Validate model fields by these rules
* @var array
*/
protected $rules = [
'full_name' => 'required',
'username' => 'required|unique:codebugs_auth_users,username',
'password' => 'required',
'email' => 'required|email',
'site_id' => 'required'
];
/**
* @var array Relations
*/
public $hasOne = [];
public $hasMany = [];
public $belongsTo = [
'site' => ['Codebugs\Master\Models\Site', 'primaryKey' => 'id']
];
public $belongsToMany = [];
public $morphTo = [];
public $morphOne = [];
public $morphMany = [];
public $attachOne = [];
public $attachMany = [];
public function getSiteIdOptions($keyValue = null)
{
return Site::where('status','Live')->orderby('name')->lists('name','id');
}
}
...and here is my fields.yaml
# ===================================
# Form Field Definitions
# ===================================
fields:
full_name:
label: Full name
type: text
span: auto
site_id:
label: Site
type: dropdown
span: auto
username:
label: Username
type: text
span: auto
password:
label: Password
type: password
span: auto
email:
label: E-mail address
type: text
span: auto
phone:
label: Phone number
label: text
span: auto
is_enabled:
label: Enabled
type: checkbox
default: true
If you should see more please just let me know.
Thank you!