10 use BristolSU\ControlDB\Contracts\Repositories\Group as GroupRepository;
11 use BristolSU\ControlDB\Contracts\Repositories\Role as RoleRepository;
32 protected $appends = [
'run_number',
'participant'];
40 'name',
'description',
'activity_id',
'resource_type',
'resource_id' 52 $activityInstances = static::newQuery()
53 ->where(
'activity_id', $this->activity_id)
54 ->where(
'resource_type', $this->resource_type)
55 ->where(
'resource_id', $this->resource_id)
56 ->orderBy(
'created_at')
58 if ($activityInstances->count() > 0) {
59 for ($i = 0; $i <= $activityInstances->count(); $i++) {
60 if ($this->is($activityInstances->offsetGet($i))) {
81 if ($this->resource_type ===
'user') {
82 return app(UserRepository::class)->getById($this->resource_id);
84 if ($this->resource_type ===
'group') {
85 return app(GroupRepository::class)->getById($this->resource_id);
87 if ($this->resource_type ===
'role') {
88 return app(RoleRepository::class)->getById($this->resource_id);
90 throw new \Exception(
'Resource type is not valid');
102 return $this->participant;
112 return $this->hasManyThrough(ModuleInstance::class, Activity::class,
'id',
'activity_id',
'activity_id',
'id');
122 return $this->belongsTo(Activity::class);
getParticipantAttribute()