mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04: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.
28 lines
687 B
PHP
28 lines
687 B
PHP
<?php
|
|
|
|
namespace BookStack\Actions;
|
|
|
|
use BookStack\Auth\Permissions\JointPermission;
|
|
use BookStack\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
class Favourite extends Model
|
|
{
|
|
protected $fillable = ['user_id'];
|
|
|
|
/**
|
|
* Get the related model that can be favourited.
|
|
*/
|
|
public function favouritable(): MorphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
|
|
public function jointPermissions(): HasMany
|
|
{
|
|
return $this->hasMany(JointPermission::class, 'entity_id', 'favouritable_id')
|
|
->whereColumn('favourites.favouritable_type', '=', 'joint_permissions.entity_type');
|
|
}
|
|
}
|