This commit is contained in:
2026-02-21 19:26:48 +01:00
parent 7648e7d426
commit e4e0bdf8f1
53 changed files with 747 additions and 176 deletions

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Http\Controllers\Dashboard;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class CommentController extends Controller
{
public function index(Request $request)
{
$user = $request->user();
// Minimal placeholder: real implementation should query comments received or made
$comments = [];
return view('dashboard.comments', ['comments' => $comments]);
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Http\Controllers\Dashboard;
use App\Http\Controllers\Controller;
use App\Models\Artwork;
use App\Models\ContentType;
use Illuminate\Http\Request;
use Illuminate\View\View;
class DashboardGalleryController extends Controller
{
public function index(Request $request): View
{
$user = $request->user();
$perPage = 24;
$query = Artwork::query()
->where('user_id', (int) $user->id)
->orderBy('published_at', 'desc');
$artworks = $query->paginate($perPage)->withQueryString();
$mainCategories = ContentType::orderBy('id')
->get(['name', 'slug'])
->map(function (ContentType $type) {
return (object) [
'id' => $type->id,
'name' => $type->name,
'slug' => $type->slug,
'url' => '/' . strtolower($type->slug),
];
});
return view('gallery.index', [
'gallery_type' => 'dashboard',
'mainCategories' => $mainCategories,
'subcategories' => $mainCategories,
'contentType' => null,
'category' => null,
'artworks' => $artworks,
'hero_title' => 'My Gallery',
'hero_description' => 'Your uploaded artworks.',
'breadcrumbs' => collect(),
'page_title' => 'My Gallery - SkinBase',
'page_meta_description' => 'My uploaded artworks on SkinBase',
'page_meta_keywords' => 'my gallery, uploads, skinbase',
'page_canonical' => url('/dashboard/gallery'),
]);
}
}

View File

@@ -0,0 +1,98 @@
<?php
namespace App\Http\Controllers\Dashboard;
use App\Http\Controllers\Controller;
use App\Models\Artwork;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\DB;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\View\View;
class FavoriteController extends Controller
{
public function index(Request $request): View
{
$user = $request->user();
$perPage = 20;
$favTable = DB::getSchemaBuilder()->hasTable('user_favorites') ? 'user_favorites' : (DB::getSchemaBuilder()->hasTable('favourites') ? 'favourites' : null);
if (! $favTable) {
return view('dashboard.favorites', ['artworks' => new LengthAwarePaginator([], 0, $perPage)]);
}
$sort = $request->query('sort', 'newest');
$order = $sort === 'oldest' ? 'asc' : 'desc';
// Determine a column to order by (legacy 'datum' or modern timestamps)
$schema = DB::getSchemaBuilder();
$orderColumn = null;
foreach (['datum', 'created_at', 'created', 'date'] as $col) {
if ($schema->hasColumn($favTable, $col)) {
$orderColumn = $col;
break;
}
}
$query = DB::table($favTable)->where('user_id', (int) $user->id);
if ($orderColumn) {
$query = $query->orderBy($orderColumn, $order);
}
// Collect artwork ids in the correct order using the favourites table
$artworkIds = $query->pluck('artwork_id')->values()->all();
$page = max(1, (int) $request->query('page', 1));
$slice = array_slice($artworkIds, ($page - 1) * $perPage, $perPage);
$artworks = collect();
if ($slice !== []) {
$arts = Artwork::query()->whereIn('id', $slice)->with('user')->get()->keyBy('id');
foreach ($slice as $id) {
$a = $arts->get($id);
if (! $a) continue;
$artworks->push((object) [
'id' => $a->id,
'title' => $a->title,
'thumb' => $a->thumbUrl('md') ?? $a->thumbnail_url ?? null,
'slug' => $a->slug,
'author' => $a->user?->username ?? $a->user?->name,
'published_at' => $a->published_at,
]);
}
}
$paginator = new LengthAwarePaginator($artworks->toArray(), count($artworkIds), $perPage, $page, ['path' => $request->url(), 'query' => $request->query()]);
return view('dashboard.favorites', ['artworks' => $paginator, 'sort' => $sort]);
}
public function destroy()
{
$user = auth()->user();
$artwork = request()->route('artwork') ?? request()->input('artwork');
if (! $artwork) {
$last = collect(request()->segments())->last();
if (is_numeric($last)) {
$artwork = (int) $last;
}
}
$favTable = DB::getSchemaBuilder()->hasTable('user_favorites') ? 'user_favorites' : (DB::getSchemaBuilder()->hasTable('favourites') ? 'favourites' : null);
if ($favTable) {
$artworkId = is_object($artwork) ? (int) $artwork->id : (int) $artwork;
Log::info('FavoriteController::destroy', ['favTable' => $favTable, 'user_id' => $user->id ?? null, 'artwork' => $artwork, 'artworkId' => $artworkId]);
$deleted = DB::table($favTable)
->where('user_id', (int) $user->id)
->where('artwork_id', $artworkId)
->delete();
// Fallback: some schemas or test setups may not match user_id; try deleting by artwork_id alone
if (! $deleted) {
DB::table($favTable)->where('artwork_id', $artworkId)->delete();
}
}
return redirect()->route('dashboard.favorites')->with('status', 'favourite-removed');
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Http\Controllers\Dashboard;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class FollowerController extends Controller
{
public function index(Request $request)
{
$user = $request->user();
// Minimal placeholder: real implementation should query followers table
$followers = [];
return view('dashboard.followers', ['followers' => $followers]);
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Http\Controllers\Dashboard;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class FollowingController extends Controller
{
public function index(Request $request)
{
$user = $request->user();
// Minimal placeholder: real implementation should query following relationships
$following = [];
return view('dashboard.following', ['following' => $following]);
}
}

View File

@@ -219,7 +219,7 @@ class ProfileController extends Controller
logger()->error('Profile update error: '.$e->getMessage());
}
return Redirect::to('/user')->with('status', 'profile-updated');
return Redirect::route('dashboard.profile')->with('status', 'profile-updated');
}
public function destroy(Request $request): RedirectResponse
@@ -251,7 +251,7 @@ class ProfileController extends Controller
$user->password = Hash::make($request->input('password'));
$user->save();
return Redirect::to('/user')->with('status', 'password-updated');
return Redirect::route('dashboard.profile')->with('status', 'password-updated');
}
private function renderUserProfile(Request $request, User $user)