Merged in bugfix/PMC-985 (pull request #6988)

PMC-985

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Paula Quispe
2019-07-22 19:20:02 +00:00
committed by Julio Cesar Laura Avendaño
21 changed files with 863 additions and 22 deletions

View File

@@ -0,0 +1,14 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class BpmnProject extends Model
{
// Set our table name
protected $table = 'BPMN_PROJECT';
protected $primaryKey = 'PRJ_UID';
// We do not have create/update timestamps for this table
public $timestamps = false;
}

View File

@@ -3,6 +3,7 @@
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
use Exception;
class User extends Model
{
@@ -39,4 +40,26 @@ class User extends Model
{
return User::find($usrUid)->groups()->get();
}
/**
* Scope for the specified user
*
* @param \Illuminate\Database\Eloquent\Builder $query @param \Illuminate\Database\Eloquent\Builder $query
* @param array $filters
*
* @return \Illuminate\Database\Eloquent\Builder
* @throws Exception
*/
public function scopeUserFilters($query, array $filters)
{
if (!empty($filters['USR_ID'])) {
$query->where('USR_ID', $filters['USR_ID']);
} elseif (!empty($filters['USR_UID'])) {
$query->where('USR_UID', $filters['USR_UID']);
} else {
throw new Exception("There are no filter for loading a user model");
}
return $query;
}
}