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