fix: workshop page
This commit is contained in:
@@ -93,6 +93,17 @@ class VideosController extends Controller
|
|||||||
', [$user->id])
|
', [$user->id])
|
||||||
->paginate($perPage);
|
->paginate($perPage);
|
||||||
|
|
||||||
|
$videosActive = Video::select('id')
|
||||||
|
->where('is_active', true)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$videosWatched = Video::select('id')
|
||||||
|
->where('is_active', true)
|
||||||
|
->whereHas('views', function ($q) use ($user) {
|
||||||
|
$q->where('user_id', $user->id);
|
||||||
|
})
|
||||||
|
->count();
|
||||||
|
|
||||||
$query->getCollection()->transform(function ($video) {
|
$query->getCollection()->transform(function ($video) {
|
||||||
return [
|
return [
|
||||||
'id' => $video->id,
|
'id' => $video->id,
|
||||||
@@ -122,6 +133,8 @@ class VideosController extends Controller
|
|||||||
'userId' => $userId,
|
'userId' => $userId,
|
||||||
'role' => $role,
|
'role' => $role,
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
|
'videosActive' => $videosActive,
|
||||||
|
'videosWatched' => $videosWatched,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ class WorkshopsController extends Controller
|
|||||||
$workshop = Workshop::with('users')->find($id);
|
$workshop = Workshop::with('users')->find($id);
|
||||||
|
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
$userId = $user->id;
|
||||||
$role = $user->role_id;
|
$role = $user->role_id;
|
||||||
|
|
||||||
if (!$workshop) {
|
if (!$workshop) {
|
||||||
@@ -197,6 +198,7 @@ class WorkshopsController extends Controller
|
|||||||
'data' => $workshop,
|
'data' => $workshop,
|
||||||
'errors' => null,
|
'errors' => null,
|
||||||
'role' => $role,
|
'role' => $role,
|
||||||
|
'userId' => $userId,
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user