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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,13 @@ class CourseController extends Controller
|
||||
{
|
||||
$courses = Course::allFuture();
|
||||
}
|
||||
foreach ($courses as $course)
|
||||
{
|
||||
if($course->ocom() != null)
|
||||
{
|
||||
$course->ocom()->updateWasGiven();
|
||||
}
|
||||
}
|
||||
return view('admin.course.index',['courses' => $courses,'mode' => $mode]);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Event;
|
||||
use App\EventType;
|
||||
use App\GoogleDriveFile;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
@@ -57,6 +58,8 @@ class EventController extends Controller
|
||||
{
|
||||
$event->weekly_msg_file = [''];
|
||||
}
|
||||
} else {
|
||||
$event->weekly_msg_file = [''];
|
||||
}
|
||||
|
||||
$event->name = request('name');
|
||||
@@ -77,11 +80,13 @@ class EventController extends Controller
|
||||
if(\request("use_weekly_msg"))
|
||||
{
|
||||
$event->use_weekly_msg = 1;
|
||||
$event->weekly_msg_publication_time = \request('date_msg');
|
||||
$event->msg = request('admin_desc');
|
||||
}
|
||||
else
|
||||
{
|
||||
$event->use_weekly_msg = 0;
|
||||
$event->weekly_msg_publication_time = null;
|
||||
$event->msg = "";
|
||||
}
|
||||
|
||||
@@ -203,7 +208,7 @@ class EventController extends Controller
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('admin.schedule.event.edit',['activity' => \App\Event::find($id)]);
|
||||
return view('admin.schedule.event.edit',['event' => \App\Event::find($id)]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,52 +220,101 @@ class EventController extends Controller
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$event = Event::find($id);
|
||||
$event = Event::findOrFail($id);
|
||||
|
||||
// if (\App\GoogleDriveFile::checkConfig())
|
||||
// {
|
||||
// if (\request()->hasFile('files'))
|
||||
// {
|
||||
// $dir = \App\GoogleDriveFile::findByPath('.Systeme/.Fichier/.MessageDeLaSemaine');
|
||||
// $files = [];
|
||||
// foreach (\request()->file('files') as $f)
|
||||
// {
|
||||
// $name = urlencode(pathinfo($f->getClientOriginalName())['filename'].'_'.uniqid().'.'.$f->getClientOriginalExtension());
|
||||
// \Storage::cloud()->putFileAs($dir->id,$f,$name);
|
||||
// array_push($files,$name);
|
||||
// }
|
||||
// $event->weekly_msg_file = $files;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $event->weekly_msg_file = [''];
|
||||
// }
|
||||
// } else {
|
||||
// $event->weekly_msg_file = [''];
|
||||
// }
|
||||
|
||||
$event->name = request('name');
|
||||
$event->date_begin = request('begin');
|
||||
$event->date_end = request('end');
|
||||
$event->date_begin = request('begin_time');
|
||||
$event->date_end = request('end_time');
|
||||
$event->user_id = \Auth::user()->id;
|
||||
$event->location = request('location');
|
||||
|
||||
if(request('is_mandatory') != null){
|
||||
$event->is_mandatory = 1;
|
||||
} else {
|
||||
$event->is_mandatory = 0;
|
||||
}
|
||||
$event->desc = request('desc');
|
||||
if(\request('msg'))
|
||||
|
||||
$event->desc = \request('admin_desc');
|
||||
|
||||
if(\request("use_weekly_msg"))
|
||||
{
|
||||
$event->msg = request('msg');
|
||||
$event->use_weekly_msg = 1;
|
||||
$event->weekly_msg_publication_time = \request('date_msg');
|
||||
$event->msg = request('admin_desc');
|
||||
}
|
||||
else
|
||||
{
|
||||
$event->use_weekly_msg = 0;
|
||||
$event->weekly_msg_publication_time = null;
|
||||
$event->msg = "";
|
||||
}
|
||||
if(\request('date_msg'))
|
||||
|
||||
if(\request("use_schedule"))
|
||||
{
|
||||
$event->date_msg = request('date_msg');
|
||||
$event->use_schedule = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$event->date_msg = "";
|
||||
$event->use_schedule = 0;
|
||||
}
|
||||
|
||||
$event->calendar_color = \request('calendar_color');
|
||||
$event->calendar_icon = \request('calendar_icon');
|
||||
|
||||
$nbLevel = 1;
|
||||
$niveaux = [];
|
||||
while (\request('level_name_'.$nbLevel))
|
||||
{
|
||||
array_push($niveaux,['name' => \request('level_name_'.$nbLevel)]);
|
||||
$nbLevel++;
|
||||
}
|
||||
|
||||
$nbPeriode = 1;
|
||||
$periodes = [];
|
||||
while (\request('periode_name_'.$nbPeriode))
|
||||
{
|
||||
array_push($periodes,[
|
||||
'name' => \request('periode_name_'.$nbPeriode),
|
||||
'begin_time' => \request('periode_begin_time_'.$nbPeriode),
|
||||
'end_time' => \request('periode_end_time_'.$nbPeriode)
|
||||
]);
|
||||
$nbPeriode++;
|
||||
}
|
||||
$event->schedule = [
|
||||
'periodes' => $periodes,
|
||||
'niveaux' => $niveaux,
|
||||
'courses' => []
|
||||
];
|
||||
|
||||
$event->save();
|
||||
|
||||
if ($event->type == 1) {
|
||||
for ($l=1; $l <= \App\Config::getData('admin_level_in_schedule_nb'); $l++) {
|
||||
for ($p=1; $p <= \App\Config::getData('admin_periode_nb'); $p++) {
|
||||
if ($event->use_schedule) {
|
||||
for ($l=1; $l < $nbLevel; $l++) {
|
||||
for ($p=1; $p < $nbPeriode; $p++) {
|
||||
|
||||
$course = new \App\Course();
|
||||
|
||||
foreach ($event->courses as $c)
|
||||
{
|
||||
if ($c->periode == $p)
|
||||
{
|
||||
if ($c->level == $l)
|
||||
{
|
||||
$course = $c;
|
||||
}
|
||||
}
|
||||
}
|
||||
$course = $event->course($p,$l);
|
||||
|
||||
$users = \App\User::all();
|
||||
$instructor = request('instruc_n'.$l.'_p'.$p);
|
||||
@@ -272,22 +326,48 @@ class EventController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$course->name = request('name_n'.$l.'_p'.$p);
|
||||
$course->user_id = $instructor;
|
||||
$course->ocom = request('ocom_n'.$l.'_p'.$p);
|
||||
$course->location = request('loc_n'.$l.'_p'.$p);
|
||||
$course->location = request('location_n'.$l.'_p'.$p);
|
||||
$course->periode = $p;
|
||||
$course->level = $l;
|
||||
$course->comment_officer = "";
|
||||
$course->comment = "";
|
||||
|
||||
$course->event_id = $event->id;
|
||||
|
||||
if(\request("use_course_n".$l."_p".$p) == 'on')
|
||||
{
|
||||
$course->name = request('name_n'.$l.'_p'.$p);
|
||||
$course->ocom = request('ocom_n'.$l.'_p'.$p);
|
||||
$course->desc = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
$course->name = "";
|
||||
$course->ocom = "";
|
||||
if (request('desc_n'.$l.'_p'.$p) == null)
|
||||
{
|
||||
$course->desc = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
$course->desc = request('desc_n'.$l.'_p'.$p);
|
||||
}
|
||||
}
|
||||
$course->comment_officer = "";
|
||||
$course->comment = "";
|
||||
$course->save();
|
||||
|
||||
$ocom = \App\OCOM::where('ocom','=',request('ocom_n'.$l.'_p'.$p))->first();
|
||||
if ($ocom != null)
|
||||
{
|
||||
$foo = $ocom->courses();
|
||||
$foo->push($course);
|
||||
$ocom->saveCourses($foo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
clog('edit','success','a modifié un évènement',null,'App\Event',$event->id);
|
||||
return redirect('/admin/schedule')->with('success','Modification à l\'événement sauvegarder à l\'horaire');
|
||||
clog('add','success','a modifier un évènement',null,'App\Event',$event->id);
|
||||
return redirect('/admin/schedule')->with('success','Événement modifier à l\'horaire');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,4 +385,35 @@ class EventController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function toJson($id)
|
||||
{
|
||||
$event = Event::findOrFail($id);
|
||||
$model = $event->schedule;
|
||||
$default_value = [];
|
||||
foreach ($model['periodes'] as $periode_index => $periode)
|
||||
{
|
||||
$niveau_array = [];
|
||||
foreach ($model['niveaux'] as $niveau_index => $niveau)
|
||||
{
|
||||
$course = $event->course($periode_index+1,$niveau_index+1);
|
||||
$use_course = "on";
|
||||
if ($course->name == null) {
|
||||
$use_course = "off";
|
||||
}
|
||||
array_push($niveau_array,[
|
||||
'ocom' => $course->ocom,
|
||||
'name' => $course->name,
|
||||
'location' => $course->location,
|
||||
'instructor' => $course->instructor(),
|
||||
'desc' => $course->desc,
|
||||
'use_course' => $use_course
|
||||
]);
|
||||
}
|
||||
array_push($default_value,$niveau_array);
|
||||
}
|
||||
$model['default_value'] = $default_value;
|
||||
$event->schedule_model = $model;
|
||||
return $event->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ class OCOMController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
OCOM::wasUpdateGivenAll();
|
||||
return view('admin.ocom.index',['ocoms' => OCOM::all()]);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,53 +63,4 @@ class ScheduleEditorController extends Controller
|
||||
{
|
||||
return view('admin.schedule.editor.levelHeader',['level_id' => $id,'level_name' => 'Niveau '.$id]);
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$evenType = new \App\EventType();
|
||||
|
||||
$evenType->name = "Soirée d'instruction régulière";
|
||||
$evenType->admin_desc = "Veuillez modifier la description admin par défaut";
|
||||
$evenType->calendar_color = "orange";
|
||||
$evenType->calendar_icon = "fas fa-book";
|
||||
$evenType->begin_time = "12:00";
|
||||
$evenType->end_time = "18:00";
|
||||
$evenType->location = "Escadron";
|
||||
$evenType->is_mandatory = true;
|
||||
$evenType->use_weekly_msg = true;
|
||||
$evenType->weekly_msg_publication_time = "-5days";
|
||||
$evenType->use_schedule = true;
|
||||
$evenType->schedule_model = [
|
||||
"periodes" => [
|
||||
0 => [
|
||||
"name" => "Periode 1",
|
||||
"begin_time" => "19:00",
|
||||
"end_time" => "20:10"
|
||||
],
|
||||
1 => [
|
||||
"name" => "Pause",
|
||||
"begin_time" => "20:10",
|
||||
"end_time" => "20:30"
|
||||
],
|
||||
2 => [
|
||||
"name" => "Periode 2",
|
||||
"begin_time" => "20:30",
|
||||
"end_time" => "21:20"
|
||||
]
|
||||
],
|
||||
"niveaux" => [
|
||||
0 => [
|
||||
"name" => "Niveau 1"
|
||||
],
|
||||
1 => [
|
||||
"name" => "Niveau 2"
|
||||
],
|
||||
2 => [
|
||||
"name" => "Niveau 3"
|
||||
]
|
||||
]
|
||||
];
|
||||
$evenType->is_promoted = true;
|
||||
//$evenType->save();
|
||||
}
|
||||
}
|
||||
|
||||
40
app/OCOM.php
40
app/OCOM.php
@@ -3,6 +3,7 @@
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use function GuzzleHttp\Promise\all;
|
||||
|
||||
/**
|
||||
* App\OCOM
|
||||
@@ -72,40 +73,47 @@ class OCOM extends Model
|
||||
|
||||
public function wasGiven()
|
||||
{
|
||||
$courses = $this->courses();
|
||||
$courses = Course::where('ocom',$this->ocom)->get();
|
||||
$result = collect();
|
||||
|
||||
$from = strtotime(\App\Config::getData('instruction_year_begin'));
|
||||
$to = strtotime(\App\Config::getData('instruction_year_end'));
|
||||
|
||||
foreach ($courses as $course)
|
||||
{
|
||||
$event = null;
|
||||
try {
|
||||
$event = $course->event;
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// Nettoyer ?
|
||||
break;
|
||||
}
|
||||
$event = $course->event;
|
||||
if (strtotime($event->date_begin) >= $from)
|
||||
{
|
||||
if (strtotime($event->date_begin) <= $to)
|
||||
{
|
||||
$result->push($event);
|
||||
$result->push($course->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($result->isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function updateWasGiven()
|
||||
{
|
||||
$this->course_id = implode(",",$this->wasGiven()->toArray());
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public static function wasUpdateGivenAll()
|
||||
{
|
||||
$ocoms = OCOM::all();
|
||||
foreach ($ocoms as $o)
|
||||
{
|
||||
$o->updateWasGiven();
|
||||
}
|
||||
}
|
||||
|
||||
public static function findByOCOM($ocom)
|
||||
{
|
||||
return OCOM::where('ocom','=',$ocom)->first();
|
||||
}
|
||||
|
||||
public function getDurationInMin()
|
||||
{
|
||||
return $this->nbPeriode * 30;
|
||||
}
|
||||
}
|
||||
|
||||
71
app/Providers/TelescopeServiceProvider.php
Normal file
71
app/Providers/TelescopeServiceProvider.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Telescope\IncomingEntry;
|
||||
use Laravel\Telescope\Telescope;
|
||||
use Laravel\Telescope\TelescopeApplicationServiceProvider;
|
||||
|
||||
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
// Telescope::night();
|
||||
|
||||
$this->hideSensitiveRequestDetails();
|
||||
|
||||
Telescope::filter(function (IncomingEntry $entry) {
|
||||
if ($this->app->environment('local')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $entry->isReportableException() ||
|
||||
$entry->isFailedRequest() ||
|
||||
$entry->isFailedJob() ||
|
||||
$entry->isScheduledTask() ||
|
||||
$entry->hasMonitoredTag();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent sensitive request details from being logged by Telescope.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function hideSensitiveRequestDetails()
|
||||
{
|
||||
if ($this->app->environment('local')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Telescope::hideRequestParameters(['_token']);
|
||||
|
||||
Telescope::hideRequestHeaders([
|
||||
'cookie',
|
||||
'x-csrf-token',
|
||||
'x-xsrf-token',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Telescope gate.
|
||||
*
|
||||
* This gate determines who can access Telescope in non-local environments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function gate()
|
||||
{
|
||||
Gate::define('viewTelescope', function ($user) {
|
||||
return in_array($user->email, [
|
||||
//
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user