/home/techb158/ileadtechnology.com/app/Http/Controllers
Edit: /home/techb158/ileadtechnology.com/app/Http/Controllers/WatchController.php (11634B)
where('user_id', Auth::User()->id)->where('course_id', $id)->first();
$courses = Course::where('id', $id)->first();
$bundle = Order::where('user_id', Auth::User()->id)->where('bundle_id', '!=', NULL)->get();
$gsetting = Setting::first();
$course_id = array();
foreach($bundle as $b)
{
$bundle = BundleCourse::where('id', $b->bundle_id)->first();
array_push($course_id, $bundle->course_id);
}
$course_id = array_values(array_filter($course_id));
$course_id = array_flatten($course_id);
if(Auth::User()->role == "admin")
{
return view('watch',compact('courses'));
}
else
{
if(!empty($order))
{
$coursewatch = WatchCourse::where('course_id','=',$id)->where('user_id', Auth::User()->id)->first();
if($gsetting->device_control == 1)
{
if(!$coursewatch)
{
$watching = WatchCourse::create([
'user_id' => Auth::user()->id,
'course_id' => $id,
'start_time' => \Carbon\Carbon::now()->toDateTimeString(),
'active' => '1',
'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
]
);
return view('watch',compact('courses'));
}
else{
if($coursewatch->active == 0){
$coursewatch->active = 1;
$coursewatch->save();
return view('watch',compact('courses'));
}
else{
Alert::error('Active', 'User Already Watching Course !!');
return back();
}
}
}
else{
return view('watch',compact('courses'));
}
}
elseif(isset($course_id) && in_array($id, $course_id))
{
return view('watch',compact('courses'));
}
else
{
return back()->with('delete', trans('flash.UnauthorizedAction'));
}
}
}
return Redirect::route('login')->withInput()->with('delete', trans('flash.PleaseLogin'));
}
public function watchclass($id)
{
$class = CourseClass::where('id',$id)->first();
$courses = Course::where('id', $class->course_id)->first();
if(Auth::check())
{
$order = Order::where('status', '1')->where('user_id', Auth::User()->id)->where('course_id', $courses->id)->first();
$gsetting = Setting::first();
$bundle = Order::where('user_id', Auth::User()->id)->where('bundle_id', '!=', NULL)->get();
$course_id = array();
foreach($bundle as $b)
{
$bundle = BundleCourse::where('id', $b->bundle_id)->first();
array_push($course_id, $bundle->course_id);
}
$course_id = array_values(array_filter($course_id));
$course_id = array_flatten($course_id);
if(Auth::User()->role == "admin")
{
return view('classwatch',compact('class'));
}
else
{
if(!empty($order))
{
$coursewatch = WatchCourse::where('course_id','=',$courses->id)->where('user_id', Auth::User()->id)->first();
if($gsetting->device_control == 1)
{
if(!$coursewatch)
{
$watching = WatchCourse::create([
'user_id' => Auth::user()->id,
'course_id' => $courses->id,
'start_time' => \Carbon\Carbon::now()->toDateTimeString(),
'active' => '1',
'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
]
);
return view('classwatch',compact('class'));
}
else{
if($coursewatch->active == 0){
$coursewatch->active = 1;
$coursewatch->save();
return view('classwatch',compact('class'));
}
else{
Alert::error('Active', 'User Already Watching Course !!');
return back();
}
}
}
else{
return view('classwatch',compact('class'));
}
}
elseif(isset($course_id) && in_array($courses->id, $course_id))
{
return view('classwatch',compact('class'));
}
else
{
return back()->with('delete', trans('flash.UnauthorizedAction'));
}
}
}
return Redirect::route('login')->withInput()->with('delete', trans('flash.PleaseLogin'));
}
public function view($url, $course_id)
{
$course = $course_id;
$url = Crypt::decrypt($url);
if(Auth::check())
{
$order = Order::where('status', '1')->where('user_id', Auth::User()->id)->where('course_id', $course)->first();
$gsetting = Setting::first();
$bundle = Order::where('user_id', Auth::User()->id)->where('bundle_id', '!=', NULL)->get();
$course_id = array();
foreach($bundle as $b)
{
$bundle = BundleCourse::where('id', $b->bundle_id)->first();
array_push($course_id, $bundle->course_id);
}
$course_id = array_values(array_filter($course_id));
$course_id = array_flatten($course_id);
if(Auth::User()->role == "admin")
{
return view('iframe',compact('url', 'course'));
}
elseif(isset($course_id) && in_array($course, $course_id))
{
return view('iframe',compact('url', 'course'));
}
else
{
if(!empty($order))
{
return view('iframe',compact('url', 'course'));
}
else
{
return back()->with('delete', trans('flash.UnauthorizedAction'));
}
}
}
return Redirect::route('login')->withInput()->with('delete', trans('flash.PleaseLogin'));
}
public function lightbox($id)
{
$class = CourseClass::where('id',$id)->first();
return view('lightbox',compact('class'));
}
public function audioclass($id)
{
$class = CourseClass::where('id',$id)->first();
$courses = Course::where('id', $class->course_id)->first();
if(Auth::check())
{
$order = Order::where('status', '1')->where('user_id', Auth::User()->id)->where('course_id', $courses->id)->first();
$gsetting = Setting::first();
$bundle = Order::where('user_id', Auth::User()->id)->where('bundle_id', '!=', NULL)->get();
$course_id = array();
foreach($bundle as $b)
{
$bundle = BundleCourse::where('id', $b->bundle_id)->first();
array_push($course_id, $bundle->course_id);
}
$course_id = array_values(array_filter($course_id));
$course_id = array_flatten($course_id);
if(Auth::User()->role == "admin")
{
return view('audioclass',compact('class'));
}
else
{
if(!empty($order))
{
$coursewatch = WatchCourse::where('course_id','=',$courses->id)->where('user_id', Auth::User()->id)->first();
if($gsetting->device_control == 1)
{
if(!$coursewatch)
{
$watching = WatchCourse::create([
'user_id' => Auth::user()->id,
'course_id' => $courses->id,
'start_time' => \Carbon\Carbon::now()->toDateTimeString(),
'active' => '1',
'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
]
);
return view('audioclass',compact('class'));
}
else{
if($coursewatch->active == 0){
$coursewatch->active = 1;
$coursewatch->save();
return view('audioclass',compact('class'));
}
else{
Alert::error('Active', 'User Already Watching Course !!');
return back();
}
}
}
else{
return view('audioclass',compact('class'));
}
}
elseif(isset($course_id) && in_array($courses->id, $course_id))
{
return view('audioclass',compact('class'));
}
else
{
return back()->with('delete', trans('flash.UnauthorizedAction'));
}
}
}
return Redirect::route('login')->withInput()->with('delete', trans('flash.PleaseLogin'));
}
}