Scaffolded from the Ladill mini/events extraction pattern: multi-file transfers, retention controls, public landing pages, analytics, and Gitea deploy workflow. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Transfer;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Transfer;
|
|
use App\Models\TransferFile;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class FilesController extends Controller
|
|
{
|
|
public function index(Request $request): View
|
|
{
|
|
$account = ladill_account();
|
|
|
|
$files = TransferFile::query()
|
|
->whereHas('transfer', fn ($q) => $q
|
|
->where('user_id', $account->id)
|
|
->where('status', Transfer::STATUS_ACTIVE))
|
|
->with('transfer')
|
|
->latest()
|
|
->paginate(30);
|
|
|
|
$storageBytes = Transfer::query()
|
|
->where('user_id', $account->id)
|
|
->where('status', Transfer::STATUS_ACTIVE)
|
|
->sum('storage_bytes');
|
|
|
|
return view('transfer.files.index', [
|
|
'files' => $files,
|
|
'storageBytes' => (int) $storageBytes,
|
|
'storageGb' => round($storageBytes / (1024 * 1024 * 1024), 2),
|
|
'pricePerGb' => (float) config('transfer.price_per_gb_month', 1.0),
|
|
]);
|
|
}
|
|
}
|