mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-30 15:42:41 +01:00
2d1f1abce4
Is a tweak upon the existing approach, mainly to store and query role permission access in a way that allows muli-level states that may override eachother. These states are represented in the new PermissionStatus class. This also simplifies how own permissions are stored and queried, to be part of a single column.
36 lines
823 B
PHP
36 lines
823 B
PHP
<?php
|
|
|
|
namespace BookStack\References;
|
|
|
|
use BookStack\Auth\Permissions\JointPermission;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
/**
|
|
* @property int $from_id
|
|
* @property string $from_type
|
|
* @property int $to_id
|
|
* @property string $to_type
|
|
*/
|
|
class Reference extends Model
|
|
{
|
|
public $timestamps = false;
|
|
|
|
public function from(): MorphTo
|
|
{
|
|
return $this->morphTo('from');
|
|
}
|
|
|
|
public function to(): MorphTo
|
|
{
|
|
return $this->morphTo('to');
|
|
}
|
|
|
|
public function jointPermissions(): HasMany
|
|
{
|
|
return $this->hasMany(JointPermission::class, 'entity_id', 'from_id')
|
|
->whereColumn('references.from_type', '=', 'joint_permissions.entity_type');
|
|
}
|
|
}
|