2021-06-26 17:23:15 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Actions;
|
2021-05-16 01:29:56 +02:00
|
|
|
|
2023-01-24 15:55:34 +01:00
|
|
|
use BookStack\Auth\Permissions\JointPermission;
|
2021-05-16 01:29:56 +02:00
|
|
|
use BookStack\Model;
|
2023-01-24 15:55:34 +01:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
2021-05-16 01:29:56 +02:00
|
|
|
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();
|
|
|
|
}
|
2023-01-24 15:55:34 +01:00
|
|
|
|
|
|
|
public function jointPermissions(): HasMany
|
|
|
|
{
|
|
|
|
return $this->hasMany(JointPermission::class, 'entity_id', 'favouritable_id')
|
|
|
|
->whereColumn('favourites.favouritable_type', '=', 'joint_permissions.entity_type');
|
|
|
|
}
|
2021-05-16 01:29:56 +02:00
|
|
|
}
|