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.
 
 

56 lines
1.2 KiB

<?php
namespace App\Models;
use App\Models\Model;
class Tag extends Model
{
protected $fillable = ['business_id', 'label', 'color'];
protected $reportable = [
'label', 'color'
];
public function getValueOf(?string $key)
{
$values = [
'business_id' => $this->business_id,
'project_id' => null,
'sprint_id' => null,
'workflow_id' => null,
'status_id' => null,
'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 rules()
{
return [
'label' => 'required|string|min:3|max:225',
'color' => 'nullable|string|min:2|max:255',
];
}
public function business()
{
return $this->belongsTo(Business::class,'business_id','id',__FUNCTION__);
}
public function task()
{
return $this->belongsToMany(
Task::class,'tag_task','tag_id','task_id',
'id','id',__FUNCTION__
);
}
}