mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 02:39:10 -04:00
Working schedule v2
This commit is contained in:
@@ -59,19 +59,27 @@ class Course extends Model
|
||||
|
||||
public function instructor()
|
||||
{
|
||||
if (\App\User::find($this->user_id))
|
||||
{
|
||||
if (\App\User::find($this->user_id)) {
|
||||
return \App\User::find($this->user_id)->fullname();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return $this->user_id;
|
||||
}
|
||||
}
|
||||
|
||||
public function ocom()
|
||||
{
|
||||
if ($this->ocom != null) {
|
||||
$ocom = \App\OCOM::findByOCOM($this->ocom);
|
||||
if ($ocom != null) {
|
||||
return $ocom;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function event()
|
||||
{
|
||||
return $this->belongsTo('App\Event');
|
||||
return $this->belongsTo('App\Event');
|
||||
}
|
||||
|
||||
public function logs()
|
||||
@@ -92,10 +100,8 @@ class Course extends Model
|
||||
public static function allFuture()
|
||||
{
|
||||
$courses = Course::all();
|
||||
foreach ($courses as $key => $course)
|
||||
{
|
||||
if (date('c',strtotime($course->event->date_begin)) <= date('c'))
|
||||
{
|
||||
foreach ($courses as $key => $course) {
|
||||
if (date('c', strtotime($course->event->date_begin)) <= date('c')) {
|
||||
$courses->forget($key);
|
||||
}
|
||||
}
|
||||
@@ -105,14 +111,11 @@ class Course extends Model
|
||||
public static function allThisYear()
|
||||
{
|
||||
$courses = Course::all();
|
||||
foreach ($courses as $key => $course)
|
||||
{
|
||||
if (date('c',strtotime($course->event->date_begin)) <= date('c',strtotime(\App\Config::getData('instruction_year_begin'))))
|
||||
{
|
||||
foreach ($courses as $key => $course) {
|
||||
if (date('c', strtotime($course->event->date_begin)) <= date('c', strtotime(\App\Config::getData('instruction_year_begin')))) {
|
||||
$courses->forget($key);
|
||||
}
|
||||
if (date('c',strtotime($course->event->date_begin)) >= date('c',strtotime(\App\Config::getData('instruction_year_end'))))
|
||||
{
|
||||
if (date('c', strtotime($course->event->date_begin)) >= date('c', strtotime(\App\Config::getData('instruction_year_end')))) {
|
||||
$courses->forget($key);
|
||||
}
|
||||
}
|
||||
@@ -122,10 +125,8 @@ class Course extends Model
|
||||
public static function allForUser($user_id)
|
||||
{
|
||||
$courses = Course::all();
|
||||
foreach ($courses as $key => $course)
|
||||
{
|
||||
if ($course->user_id != $user_id)
|
||||
{
|
||||
foreach ($courses as $key => $course) {
|
||||
if ($course->user_id != $user_id) {
|
||||
$courses->forget($key);
|
||||
}
|
||||
}
|
||||
@@ -140,14 +141,11 @@ class Course extends Model
|
||||
public static function allFutureForUser($user_id)
|
||||
{
|
||||
$courses = Course::all();
|
||||
foreach ($courses as $key => $course)
|
||||
{
|
||||
if (date('c',strtotime($course->event->date_begin)) <= date('c'))
|
||||
{
|
||||
foreach ($courses as $key => $course) {
|
||||
if (date('c', strtotime($course->event->date_begin)) <= date('c')) {
|
||||
$courses->forget($key);
|
||||
}
|
||||
if ($course->user_id != $user_id)
|
||||
{
|
||||
if ($course->user_id != $user_id) {
|
||||
$courses->forget($key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user