mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 22:39:34 +00:00
44 lines
933 B
PHP
44 lines
933 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class MasterTask extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
public $timestamps = true;
|
|
|
|
public function subtasks()
|
|
{
|
|
return $this->hasMany(SubTask::class);
|
|
}
|
|
|
|
public function project()
|
|
{
|
|
return $this->belongsTo(Project::class);
|
|
}
|
|
|
|
public function attachments()
|
|
{
|
|
return $this->hasMany(Attachment::class);
|
|
}
|
|
|
|
public function team()
|
|
{
|
|
return $this->belongsTo(Team::class);
|
|
}
|
|
|
|
// vracia userov, ktori su priradeni k subtasku ale nepatria do teamu
|
|
public function getUsersOutsideTeamAttribute()
|
|
{
|
|
$users = $this->subtasks->pluck('user')->unique();
|
|
|
|
return $users->filter(function ($user) {
|
|
return !in_array($this->team->id, $user->teams->pluck('id')->unique()->toArray());
|
|
});
|
|
}
|
|
}
|