1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Models/UserAccount.php
Holger Lösken 0fbda85a59 Code Refactoring
- Removed unused uses
- Type hinting for method parameters
- Removed commented code
- Introduced comments for classes and methods
- Short array syntax
2016-07-03 16:19:22 +00:00

69 lines
1.2 KiB
PHP

<?php namespace App\Models;
use Eloquent;
/**
* Class UserAccount
*/
class UserAccount extends Eloquent
{
/**
* @var bool
*/
public $timestamps = false;
/**
* @param $userId
* @return bool
*/
public function hasUserId($userId)
{
if (!$userId) {
return false;
}
for ($i=1; $i<=5; $i++) {
$field = "user_id{$i}";
if ($this->$field && $this->$field == $userId) {
return true;
}
}
return false;
}
/**
* @param $userId
*/
public function setUserId($userId)
{
if (self::hasUserId($userId)) {
return;
}
for ($i=1; $i<=5; $i++) {
$field = "user_id{$i}";
if (!$this->$field) {
$this->$field = $userId;
break;
}
}
}
/**
* @param $userId
*/
public function removeUserId($userId)
{
if (!$userId || !self::hasUserId($userId)) {
return;
}
for ($i=1; $i<=5; $i++) {
$field = "user_id{$i}";
if ($this->$field && $this->$field == $userId) {
$this->$field = null;
}
}
}
}