|
|
<?php
namespace App\Models;
use App\Models\Model;
class Sprint extends Model { protected $table = 'sprints';
protected $fillable = ['business_id', 'project_id', 'name', 'description', 'started_at', 'ended_at', 'active'];
protected $reportable = [ 'name', 'started_at', 'ended_at', // fields
];
public function rules() { return [ 'name' => 'bail|required|string|min:2|max:225', 'started_at' => 'bail|required|date|date_format:Y-m-d', 'ended_at' => 'bail|required|date|date_format:Y-m-d|after:started_at', 'active' => 'nullable|boolean', 'description' => 'nullable|string|min:2|max:1000', ]; }
protected $casts = [ 'active' => 'boolean' ];
public function getValueOf(?string $key) { $values = [ 'business_id' => $this->business_id, 'project_id' => $this->project_id, 'sprint_id' => $this->id, '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 business() { return $this->belongsTo(Business::class, 'business_id', 'id'); }
public function projects() { return $this->belongsTo(Project::class, 'project_id', 'id'); }
public function tasks() { return $this->hasMany(Task::class, 'sprint_id', 'id'); }
}
|