2017-12-04 13:25:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace ProcessMaker\Model;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class Process
|
|
|
|
|
* @package ProcessMaker\Model
|
|
|
|
|
*
|
|
|
|
|
* Represents a business process object in the system.
|
|
|
|
|
*/
|
|
|
|
|
class Process extends Model
|
|
|
|
|
{
|
|
|
|
|
// Set our table name
|
|
|
|
|
protected $table = 'PROCESS';
|
2019-04-25 14:15:41 -07:00
|
|
|
// Our custom timestamp columns
|
2017-12-04 13:25:35 +00:00
|
|
|
const CREATED_AT = 'PRO_CREATE_DATE';
|
2019-04-25 14:15:41 -07:00
|
|
|
const UPDATED_AT = 'PRO_UPDATE_DATE';
|
2019-04-25 13:54:39 -07:00
|
|
|
/**
|
|
|
|
|
* Retrieve all applications that belong to this process
|
|
|
|
|
*/
|
|
|
|
|
public function applications()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Application::class, 'PRO_ID', 'PRO_ID');
|
|
|
|
|
}
|
2019-04-25 14:15:41 -07:00
|
|
|
|
2019-04-25 21:15:43 -04:00
|
|
|
public function tasks()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Task::class, 'PRO_UID', 'PRO_UID');
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-25 14:15:41 -07:00
|
|
|
public function creator()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(User::class, 'PRO_CREATE_USER', 'USR_UID');
|
|
|
|
|
}
|
2019-05-02 12:46:53 -04:00
|
|
|
|
|
|
|
|
public function category()
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(ProcessCategory::class, 'PRO_CATEGORY', 'CATEGORY_UID');
|
|
|
|
|
}
|
2019-07-25 14:50:06 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Obtains the process list for an specific user and/or for the specific category
|
|
|
|
|
*
|
|
|
|
|
* @param string $categoryUid
|
|
|
|
|
* @param string $userUid
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @see ProcessMaker\BusinessModel\Light::getProcessList()
|
|
|
|
|
*/
|
|
|
|
|
public function getProcessList($categoryUid, $userUid)
|
|
|
|
|
{
|
|
|
|
|
$selectedColumns = ['PRO_UID', 'PRO_TITLE'];
|
|
|
|
|
$query = Process::query()
|
|
|
|
|
->select($selectedColumns)
|
|
|
|
|
->where('PRO_STATUS', 'ACTIVE')
|
|
|
|
|
->where('PRO_CREATE_USER', $userUid);
|
|
|
|
|
|
|
|
|
|
if (!empty($categoryUid)) {
|
|
|
|
|
$query->where('PRO_CATEGORY', $categoryUid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ($query->get()->values()->toArray());
|
|
|
|
|
}
|
2019-05-02 12:46:53 -04:00
|
|
|
}
|