Upload beautify
This commit is contained in:
41
app/Http/Controllers/Web/GalleryController.php
Normal file
41
app/Http/Controllers/Web/GalleryController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Artwork;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class GalleryController extends Controller
|
||||
{
|
||||
public function show(Request $request, $userId, $username = null)
|
||||
{
|
||||
$user = User::find((int)$userId);
|
||||
if (! $user) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$page = max(1, (int) $request->query('page', 1));
|
||||
$hits = 20;
|
||||
|
||||
$query = Artwork::where('user_id', $user->id)
|
||||
->approved()
|
||||
->published()
|
||||
->public()
|
||||
->orderByDesc('published_at');
|
||||
|
||||
$total = (int) $query->count();
|
||||
|
||||
$artworks = $query->skip(($page - 1) * $hits)->take($hits)->get();
|
||||
|
||||
return view('web.gallery', [
|
||||
'user' => $user,
|
||||
'artworks' => $artworks,
|
||||
'page' => $page,
|
||||
'hits' => $hits,
|
||||
'total' => $total,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user