����JFIF��x�x����'
Server IP : 66.29.137.217 / Your IP : 3.22.79.2 Web Server : LiteSpeed System : Linux premium294.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : gltevjme ( 1095) PHP Version : 7.0.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/gltevjme/cbt.bofirm.com/app/Http/Controllers/User/ |
Upload File : |
<?php namespace App\Http\Controllers\User; use App\Filters\LessonFilters; use App\Http\Controllers\Controller; use App\Models\Section; use App\Models\Skill; use App\Models\SubCategory; use App\Transformers\User\PracticeLessonTransformer; use Illuminate\Http\Request; use Inertia\Inertia; class PracticeLessonController extends Controller { private int $perPage = 10; /** * Skill Lessons Page * * @param SubCategory $category * @param Section $section * @param $skill * @return \Inertia\Response */ public function skillLessons(SubCategory $category, Section $section, $skill) { $skill = Skill::where('slug', $skill)->firstOrFail(); return Inertia::render('User/PracticeLessons', [ 'category' => $category, 'section' => $section, 'skill' => $skill, 'subscription' => request()->user()->hasActiveSubscription($category->id, 'lessons') ]); } /** * Fetch lessons of a skill * * @param Request $request * @param SubCategory $category * @param Section $section * @param $skill * @param LessonFilters $filters * @return \Illuminate\Http\JsonResponse */ public function fetchPracticeLessons(Request $request, SubCategory $category, Section $section, $skill, LessonFilters $filters) { $skill = Skill::where('slug', $skill)->firstOrFail(); $subscription = request()->user()->hasActiveSubscription($category->id, 'lessons'); $body = $request->has('withBody'); $lessons = fractal($skill->practiceLessons()->filter($filters)->where('sub_category_id', $category->id) ->orderBy('lessons.is_paid', 'asc') ->paginate($this->perPage), new PracticeLessonTransformer($body, $subscription)) ->toArray(); return response()->json([ 'lessons' => $lessons['data'], 'pagination' => $lessons['meta']['pagination'], ], 200); } /** * Go to Lesson read mode * * @param Request $request * @param SubCategory $category * @param Section $section * @param $skill * @return \Inertia\Response */ public function readLessons(Request $request, SubCategory $category, Section $section, $skill) { $skill = Skill::where('slug', $skill)->firstOrFail(); $subscription = request()->user()->hasActiveSubscription($category->id, 'lessons'); $currentItem = 1; if($request->has('start')) { $currentItem = (int) $request->get('start') + 1; } $index = ceil($currentItem%$this->perPage); return Inertia::render('User/LessonScreen', [ 'category' => $category, 'section' => $section, 'skill' => $skill, 'currentPage' => ceil($currentItem/$this->perPage), 'lessonIndex' => $index == 0 ? 0 : $index-1, 'subscription' => $subscription ]); } }