3 namespace BookStack\References;
5 use BookStack\Auth\Permissions\JointPermission;
6 use Illuminate\Database\Eloquent\Model;
7 use Illuminate\Database\Eloquent\Relations\HasMany;
8 use Illuminate\Database\Eloquent\Relations\MorphTo;
11 * @property int $from_id
12 * @property string $from_type
13 * @property int $to_id
14 * @property string $to_type
16 class Reference extends Model
18 public $timestamps = false;
20 public function from(): MorphTo
22 return $this->morphTo('from');
25 public function to(): MorphTo
27 return $this->morphTo('to');
30 public function jointPermissions(): HasMany
32 return $this->hasMany(JointPermission::class, 'entity_id', 'from_id')
33 ->whereColumn('references.from_type', '=', 'joint_permissions.entity_type');