forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessRequestLock.php
More file actions
62 lines (55 loc) · 1.51 KB
/
ProcessRequestLock.php
File metadata and controls
62 lines (55 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace ProcessMaker\Models;
use ProcessMaker\Traits\SqlsrvSupportTrait;
/**
* Represents an Eloquent model of a Request which is an instance of a Process.
*
* @property int $id
* @property int $process_request_id
* @property int $process_request_token_id
* @property \Carbon\Carbon $updated_at
* @property \Carbon\Carbon $created_at
* @property ProcessRequest $processRequest
* @method static \Illuminate\Database\Eloquent\Builder|\ProcessMaker\Models\ProcessRequestLock whereNotDue()
*/
class ProcessRequestLock extends ProcessMakerModel
{
use SqlsrvSupportTrait;
/**
* The attributes that aren't mass assignable.
*
* @var array
*/
protected $guarded = [
'id',
'created_at',
'updated_at',
'due_at',
];
protected $casts = [
'due_at' => 'datetime',
'request_ids' => 'array',
];
/**
* Active block that did not overcome.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeWhereNotDue($query)
{
return $query->where(function ($query) {
return $query->whereNull('due_at')
->orWhere('due_at', '>', now());
});
}
/**
* @return void
*/
public function activate()
{
$numSeconds = config('app.bpmn_actions_max_lock_time', 1) ?: 60;
$this->due_at = now()->modify(now()->modify("+{$numSeconds} seconds"));
$this->save();
}
}