Files
luos/workflow/engine/src/ProcessMaker/Model/Triggers.php

81 lines
1.7 KiB
PHP
Raw Normal View History

2019-06-28 15:20:51 -04:00
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class Triggers extends Model
{
// Set our table name
protected $table = 'TRIGGERS';
// No timestamps
public $timestamps = false;
2019-10-07 09:05:05 -04:00
// Primary key
2019-06-28 15:20:51 -04:00
protected $primaryKey = 'TRI_UID';
2019-10-07 09:05:05 -04:00
// No incrementing
public $incrementing = false;
2019-06-28 15:20:51 -04:00
2019-10-07 09:05:05 -04:00
// Filter by a specific uid
private $triUid = '';
/**
* Set trigger uid
*
* @param string $triUid
*/
public function setTrigger($triUid)
{
$this->triUid = $triUid;
}
/**
* Get trigger uid
*
* @return int
*/
public function getTrigger()
{
return $this->triUid;
}
2019-06-28 15:20:51 -04:00
/**
* Scope a query to filter an specific process
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $columns
* @return \Illuminate\Database\Eloquent\Builder
*/
2019-10-07 09:05:05 -04:00
public function scopeProcess($query, string $proUid)
{
return $query->where('PRO_UID', $proUid);
}
/**
* Scope a query to filter an specific trigger
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $triUid
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTrigger($query, string $triUid)
2019-06-28 15:20:51 -04:00
{
2019-10-07 09:05:05 -04:00
return $query->where('TRI_UID', $triUid);
}
/**
* Get the records
*
* @return array
*/
public function triggers()
{
$query = Triggers::query()->select();
// Specific trigger
if (!empty($this->getTrigger())) {
$query->trigger($this->getTrigger());
}
$results = $query->get()->toArray();
return $results;
2019-06-28 15:20:51 -04:00
}
}