You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
55 lines
1.2 KiB
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
use App\HiLib\Models\Model;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class Status extends Model
|
|
{
|
|
protected $table = 'statuses';
|
|
|
|
protected $fillable = [
|
|
'business_id', 'workflow_id', 'name', 'state', 'order'
|
|
];
|
|
|
|
protected $reportable = [
|
|
'name', 'state', 'order'
|
|
];
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
'name' =>'required|string|min:3|max:255',
|
|
'state' => 'nullable|between:0,3',
|
|
'order' => 'nullable|numeric|min:0'
|
|
];
|
|
}
|
|
|
|
public function getValueOf(?string $key)
|
|
{
|
|
$values = [
|
|
'business_id' => $this->business_id,
|
|
'project_id' => null,
|
|
'sprint_id' => null,
|
|
'workflow_id' => $this->workflow_id,
|
|
'status_id' => $this->id,
|
|
'system_id' => null,
|
|
'user_id' => null,
|
|
'task_id' => null,
|
|
'subject_id' => $this->id,
|
|
];
|
|
|
|
if ($key && isset($values, $key)) {
|
|
return $values[$key];
|
|
}
|
|
|
|
return $values;
|
|
}
|
|
|
|
public function workflow()
|
|
{
|
|
return $this->belongsTo(Workflow::class,'workflow_id','id');
|
|
}
|
|
}
|