Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/cms.ncriptech.com/app/Http/Controllers/Student/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php namespace App\Http\Controllers\Student; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\Student; use App\Models\Content; use Carbon\Carbon; use Auth; class DownloadCenterController extends Controller { /** * Create a new controller instance. * * @return void */ public function __construct() { // Module Data $this->title = trans_choice('module_download', 1); $this->route = 'student.download'; $this->view = 'student.download'; $this->path = 'content'; } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // $data['title'] = $this->title; $data['route'] = $this->route; $data['view'] = $this->view; $data['path'] = $this->path; $user = Student::where('id', Auth::guard('student')->user()->id)->firstOrFail(); // Filter Contents $contents = Content::where('status', '1')->where('date', '<=', Carbon::today()); $contents->with('students')->whereHas('students', function ($query) use ($user){ $query->where('contentable_id', $user->id); $query->where('contentable_type', 'App\Models\Student'); }); $data['rows'] = $contents->orderBy('date', 'desc')->get(); return view($this->view.'.index', $data); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // $data['title'] = $this->title; $data['route'] = $this->route; $data['view'] = $this->view; $data['path'] = $this->path; $user = Student::where('id', Auth::guard('student')->user()->id)->firstOrFail(); // Filter Contents $contents = Content::where('status', '1')->where('date', '<=', Carbon::today()); $contents->with('students')->whereHas('students', function ($query) use ($user){ $query->where('contentable_id', $user->id); $query->where('contentable_type', 'App\Models\Student'); }); $data['row'] = $contents->where('id', $id)->firstOrFail(); // Read Notifications foreach ($user->unreadNotifications as $notification) { if($notification->data['type'] == 'content' && $notification->data['id'] == $id) { $notification->markAsRead(); } } return view($this->view.'.show', $data); } }