2019-04-25 13:47:21 -07:00
|
|
|
<?php
|
|
|
|
|
|
2019-04-25 13:54:39 -07:00
|
|
|
namespace ProcessMaker\Model;
|
2019-04-25 13:47:21 -07:00
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
class User extends Model
|
|
|
|
|
{
|
|
|
|
|
protected $table = "USERS";
|
2019-05-13 16:44:40 -04:00
|
|
|
protected $primaryKey = 'USR_ID';
|
2019-04-25 14:15:41 -07:00
|
|
|
// Our custom timestamp columns
|
|
|
|
|
const CREATED_AT = 'USR_CREATE_DATE';
|
|
|
|
|
const UPDATED_AT = 'USR_UPDATE_DATE';
|
2019-04-25 13:47:21 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the delegations this user has (all of them)
|
|
|
|
|
*/
|
|
|
|
|
public function delegations()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Delegation::class, 'USR_ID', 'USR_ID');
|
|
|
|
|
}
|
2019-05-13 16:44:40 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the user this belongs to
|
|
|
|
|
*/
|
|
|
|
|
public function groups()
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(GroupUser::class, 'USR_UID', 'USR_UID');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the groups from a user
|
|
|
|
|
*
|
|
|
|
|
* @param boolean $usrUid
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public static function getGroups($usrUid)
|
|
|
|
|
{
|
|
|
|
|
return User::find($usrUid)->groups()->get();
|
|
|
|
|
}
|
2019-04-25 13:47:21 -07:00
|
|
|
}
|