BookStack/app/Activity/Models/Favourite.php

28 lines
701 B
PHP
Raw Normal View History

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