mirror of
https://github.com/BillyOutlast/UNIT3D.git
synced 2026-02-04 03:01:20 +01:00
update: save timestamps of when torrents are added to playlists
This commit is contained in:
@@ -123,7 +123,8 @@ class PlaylistController extends Controller
|
||||
$randomTorrent?->category?->movie_meta => Movie::find($randomTorrent->tmdb),
|
||||
default => null,
|
||||
},
|
||||
'torrents' => $torrents,
|
||||
'latestPlaylistTorrent' => $playlist->torrents()->orderByPivot('created_at', 'desc')->first(),
|
||||
'torrents' => $torrents,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class Playlist extends Model
|
||||
*/
|
||||
public function torrents(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Torrent::class, 'playlist_torrents')->using(PlaylistTorrent::class)->withPivot('id');
|
||||
return $this->belongsToMany(Torrent::class, 'playlist_torrents')->using(PlaylistTorrent::class)->withPivot('id')->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,13 +36,6 @@ class PlaylistTorrent extends Pivot
|
||||
/** @use HasFactory<\Database\Factories\PlaylistTorrentFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* Indicates If The Model Should Be Timestamped.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* Indicates if the IDs are auto-incrementing.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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 Roardom <roardom@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('playlist_torrents', function (Blueprint $table): void {
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
DB::table('playlist_torrents')
|
||||
->join('playlists', 'playlist_torrents.playlist_id', '=', 'playlists.id')
|
||||
->update([
|
||||
'playlist_torrents.created_at' => DB::raw('playlists.created_at'),
|
||||
'playlist_torrents.updated_at' => DB::raw('playlists.created_at'),
|
||||
]);
|
||||
}
|
||||
};
|
||||
@@ -36,4 +36,5 @@ return [
|
||||
'title' => 'Title',
|
||||
'titles' => 'Titles',
|
||||
'update-success' => 'Your Playlist Has Successfully Been Updated!',
|
||||
'last-addition-at' => 'Last addition at',
|
||||
];
|
||||
|
||||
@@ -127,6 +127,46 @@
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
<section class="panelV2">
|
||||
<h2 class="panel__heading">{{ __('common.info') }}</h2>
|
||||
<dl class="key-value">
|
||||
<div class="key-value__group">
|
||||
<dt>{{ __('common.created_at') }}</dt>
|
||||
<dd>
|
||||
<time
|
||||
datetime="{{ $playlist->created_at }}"
|
||||
title="{{ $playlist->created_at }}"
|
||||
>
|
||||
{{ $playlist->created_at->diffForHumans() }}
|
||||
</time>
|
||||
</dd>
|
||||
</div>
|
||||
<div class="key-value__group">
|
||||
<dt>{{ __('torrent.updated_at') }}</dt>
|
||||
<dd>
|
||||
<time
|
||||
datetime="{{ $playlist->updated_at }}"
|
||||
title="{{ $playlist->updated_at }}"
|
||||
>
|
||||
{{ $playlist->updated_at->diffForHumans() }}
|
||||
</time>
|
||||
</dd>
|
||||
</div>
|
||||
@if ($latestPlaylistTorrent !== null)
|
||||
<div class="key-value__group">
|
||||
<dt>{{ __('playlist.last-addition-at') }}</dt>
|
||||
<dd>
|
||||
<time
|
||||
datetime="{{ $latestPlaylistTorrent->pivot->created_at }}"
|
||||
title="{{ $latestPlaylistTorrent->pivot->created_at }}"
|
||||
>
|
||||
{{ $latestPlaylistTorrent->pivot->created_at->diffForHumans() }}
|
||||
</time>
|
||||
</dd>
|
||||
</div>
|
||||
@endif
|
||||
</dl>
|
||||
</section>
|
||||
@endsection
|
||||
|
||||
@section('main')
|
||||
|
||||
Reference in New Issue
Block a user