This commit is contained in:
Paula Quispe
2019-05-13 16:44:40 -04:00
parent 4064c1bebf
commit ff33075228
14 changed files with 1655 additions and 303 deletions

View File

@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $table = "USERS";
protected $primaryKey = 'USR_ID';
// Our custom timestamp columns
const CREATED_AT = 'USR_CREATE_DATE';
const UPDATED_AT = 'USR_UPDATE_DATE';
@@ -18,4 +19,24 @@ class User extends Model
{
return $this->hasMany(Delegation::class, 'USR_ID', 'USR_ID');
}
/**
* 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();
}
}