mirror of
https://github.com/BillyOutlast/UNIT3D.git
synced 2026-02-05 03:31:22 +01:00
Only every 15 minutes for now instead of upon immediate completion, but it makes the code much easier to implement.
82 lines
2.3 KiB
PHP
82 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* NOTICE OF LICENSE.
|
|
*
|
|
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
|
* The details is bundled with this project in the file LICENSE.txt.
|
|
*
|
|
* @project UNIT3D Community Edition
|
|
*
|
|
* @author HDVinnie <hdinnovations@protonmail.com>
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\Auditable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* App\Models\Bookmark.
|
|
*
|
|
* @property int $id
|
|
* @property int $user_id
|
|
* @property int $torrent_id
|
|
* @property \Illuminate\Support\Carbon|null $created_at
|
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
|
*/
|
|
class Bookmark extends Model
|
|
{
|
|
use Auditable;
|
|
|
|
/** @use HasFactory<\Database\Factories\BookmarkFactory> */
|
|
use HasFactory;
|
|
|
|
/**
|
|
* Belongs To A User.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
|
|
*/
|
|
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class)->withDefault([
|
|
'username' => 'System',
|
|
'id' => User::SYSTEM_USER_ID,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Belongs To A User Setting.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<UserSetting, $this>
|
|
*/
|
|
public function userSetting(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(UserSetting::class, 'user_id', 'user_id');
|
|
}
|
|
|
|
/**
|
|
* Belongs To A History.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<History, $this>
|
|
*/
|
|
public function history(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(History::class, 'user_id', 'user_id')->whereColumn('bookmarks.torrent_id', '=', 'history.torrent_id');
|
|
}
|
|
|
|
/**
|
|
* Belongs To A Torrent.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Torrent, $this>
|
|
*/
|
|
public function torrent(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(Torrent::class);
|
|
}
|
|
}
|