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:
@@ -73,6 +73,11 @@ class Event extends Model
|
||||
return $this->hasMany('App\Course');
|
||||
}
|
||||
|
||||
public function type()
|
||||
{
|
||||
return \App\EventType::find($this->type);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\User');
|
||||
@@ -129,73 +134,13 @@ class Event extends Model
|
||||
return $events;
|
||||
}
|
||||
|
||||
public static function checkForError()
|
||||
public function nbPeriode()
|
||||
{
|
||||
$events = Event::all();
|
||||
return (count($this->schedule["periodes"]));
|
||||
}
|
||||
|
||||
$warning = [];
|
||||
$danger = [];
|
||||
|
||||
foreach ($events as $event)
|
||||
{
|
||||
if($event->date_begin == null)
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "date_begin", Incorrect');
|
||||
}
|
||||
if($event->date_end == null)
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "date_end", Incorrect');
|
||||
}
|
||||
if($event->type == null || $event->type == "" || !\App\EventType::all()->has($event->type))
|
||||
{
|
||||
$event->type = 1;
|
||||
//$event->save();
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "type", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "type", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->is_mandatory == null && $event->is_mandatory != 0)
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "is_mandatory", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "is_mandatory", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->use_weekly_msg == null && $event->use_weekly_msg != 0)
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "use_weekly_msg", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "use_weekly_msg", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->use_schedule == null && $event->use_schedule != 0)
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "use_schedule", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "use_schedule", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->schedule == null)
|
||||
{
|
||||
$event->schedule = '{"periodes":[{"name":"Periode 1","begin_time":"19:00","end_time":"20:10"},{"name":"Periode 2","begin_time":"20:30","end_time":"21:20"}],"niveaux":[{"name":"Niveau 1"},{"name":"Niveau 2"},{"name":"Niveau 3"}]}';
|
||||
$event->save();
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "schedule", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "schedule", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->location == null || $event->location == "")
|
||||
{
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "location", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "location", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->calendar_color == null || $event->calendar_color == "")
|
||||
{
|
||||
$event->calendar_color = '#A4A4A4';
|
||||
$event->save();
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "calendar_color", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "calendar_color", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
if($event->calendar_icon == null || $event->calendar_icon == "")
|
||||
{
|
||||
$event->calendar_icon = 'fas fa-book';
|
||||
$event->save();
|
||||
array_push($warning,'Évènement ID:'.$event->id.' - "calendar_icon", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
clog('error','danger','Évènement ID:'.$event->id.' - "calendar_icon", Incorrect... Réinitialisé à la valeur par défaut');
|
||||
}
|
||||
}
|
||||
|
||||
return [$warning,$danger];
|
||||
public function nbNiveau()
|
||||
{
|
||||
return count($this->schedule["niveaux"]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user