Skip to content

Commit

Permalink
Dashboad admin
Browse files Browse the repository at this point in the history
funcionalidades adicionadas ao dashboard de administrador.
  • Loading branch information
ribshow committed Jun 10, 2024
1 parent fb4ba10 commit bd7a397
Show file tree
Hide file tree
Showing 19 changed files with 1,721 additions and 129 deletions.
85 changes: 84 additions & 1 deletion app/Http/Controllers/AdmController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,97 @@
use Illuminate\Http\RedirectResponse;
use App\Models\Post;
use App\Models\User;
use App\Models\Course;
use App\Models\Discipline;
use App\Models\Blocks;
use App\Models\Room;
use App\Models\Semester;
use App\Models\Hour;

class AdmController extends Controller
{
public function index()
{
$posts = Post::all();
// usuários
$users = User::all();

return view('pages.adms.dashboard', compact('posts','users'));
// cadastrar disciplinas
$courses = Course::all();
$disciplines = Discipline::all();
$blocks = Blocks::all();
$users = User::all();
$rooms = Room::all();
$semesters = Semester::all();

// dsm 1 semestre
$dsm1 = Hour::whereIn('id', [8,9,10,11,12,13,14,15,16])->get();
// dsm 2 semestre
$dsm2 = Hour::whereIn('id', [1,2,3,4,5,6,7])->get();

return view('pages.adms.dashboard',
compact(
'posts','users',
// disciplinas
'blocks','rooms','semesters','courses','disciplines',
//dsm1 - dsm2
'dsm1','dsm2',
));
}

public function delete($id)
{
$user = User::findOrFail($id);
$user->delete();

return response()->json(['success' => 'Usuário excluído com sucesso!']);
}

public function editHour($id)
{
$hour = Hour::findOrFail($id);

return view('pages.adms.edit-hour', compact('hour'));
}

public function store(Request $request, $id)
{
$hour = Hour::findOrFail($id);
// Atualizar professor
$user = $hour->user;
$user->name = $request->user;
$user->save();

// Atualizar curso
$course = $hour->course;
$course->description = $request->course;
$course->save();

// Atualizar Semestre
$semester = $hour->semester;
$semester->name = $request->semester;
$semester->save();

// Atualizar Disciplina
$discipline = $hour->discipline;
$discipline->name = $request->discipline;
$discipline->save();

// Atualizar Sala
$room = $hour->room;
$room->name = $request->room;
$room->save();

// Atualizar Block
$block = $hour->block;
$block->block = $request->block;
$block->save();

// Atualizar Dia e Hora
$hour->dia = $request->dia;
$hour->save();

$hour->hora = $request->hora;
$hour->save();
}
}
174 changes: 172 additions & 2 deletions app/Http/Controllers/HourController.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,136 @@ public function show_dsm()
$cn6_sex_9 = Hour::find(159);
$cn6_sex_11 = Hour::find(160);

// gpi 1 semestre
$gp1_seg_7 = Hour::find(161);
$gp1_seg_9 = Hour::find(162);
$gp1_ter_7 = Hour::find(163);
$gp1_ter_9 = Hour::find(164);
$gp1_qua_7 = Hour::find(165);
$gp1_qua_9 = Hour::find(166);
$gp1_qui_7 = Hour::find(167);
$gp1_qui_9 = Hour::find(168);
$gp1_sex_7 = Hour::find(169);
$gp1_sex_9 = Hour::find(170);

// gpi 2 semestre
$gp2_seg_7 = Hour::find(171);
$gp2_seg_9 = Hour::find(172);
$gp2_ter_7 = Hour::find(173);
$gp2_ter_9 = Hour::find(174);
$gp2_qua_7 = Hour::find(175);
$gp2_qua_9 = Hour::find(176);
$gp2_qui_7 = Hour::find(177);
$gp2_qui_9 = Hour::find(178);
$gp2_sex_7 = Hour::find(179);
$gp2_sex_9 = Hour::find(180);

// gpi 3 semestre
$gp3_seg_7 = Hour::find(181);
$gp3_seg_9 = Hour::find(182);
$gp3_ter_7 = Hour::find(183);
$gp3_ter_9 = Hour::find(184);
$gp3_qua_7 = Hour::find(185);
$gp3_qua_9 = Hour::find(186);
$gp3_qui_7 = Hour::find(187);
$gp3_qui_9 = Hour::find(188);
$gp3_sex_7 = Hour::find(189);
$gp3_sex_9 = Hour::find(190);

// gpi 4 semestre
$gp4_seg_7 = Hour::find(191);
$gp4_seg_9 = Hour::find(192);
$gp4_ter_7 = Hour::find(193);
$gp4_ter_9 = Hour::find(194);
$gp4_qua_7 = Hour::find(195);
$gp4_qua_9 = Hour::find(196);
$gp4_qui_7 = Hour::find(197);
$gp4_qui_9 = Hour::find(198);
$gp4_sex_7 = Hour::find(199);
$gp4_sex_9 = Hour::find(200);

// gpi 5 semestre
$gp5_seg_7 = Hour::find(201);
$gp5_seg_9 = Hour::find(202);
$gp5_ter_7 = Hour::find(203);
$gp5_ter_9 = Hour::find(204);
$gp5_qua_7 = Hour::find(205);
$gp5_qua_9 = Hour::find(206);
$gp5_qui_7 = Hour::find(207);
$gp5_qui_9 = Hour::find(208);
$gp5_sex_7 = Hour::find(209);
$gp5_sex_9 = Hour::find(210);

// gpi 6 semestre
$gp6_seg_7 = Hour::find(211);
$gp6_seg_9 = Hour::find(212);
$gp6_ter_7 = Hour::find(213);
$gp6_ter_9 = Hour::find(214);
$gp6_qua_7 = Hour::find(215);
$gp6_qua_9 = Hour::find(216);
$gp6_qui_7 = Hour::find(217);
$gp6_qui_9 = Hour::find(218);
$gp6_sex_7 = Hour::find(219);
$gp6_sex_9 = Hour::find(220);

// ma 1 semestre
$ma1_seg_7 = Hour::find(221);
$ma1_seg_9 = Hour::find(222);
$ma1_ter_7 = Hour::find(223);
$ma1_ter_9 = Hour::find(224);
$ma1_qua_7 = Hour::find(225);
$ma1_qua_9 = Hour::find(226);
$ma1_qui_7 = Hour::find(227);
$ma1_qui_9 = Hour::find(228);
$ma1_sex_7 = Hour::find(229);
$ma1_sex_9 = Hour::find(230);
$ma1_sab_7 = Hour::find(231);
$ma1_sab_9 = Hour::find(232);

// ma 2 semestre
$ma2_seg_7 = Hour::find(233);
$ma2_seg_9 = Hour::find(234);
$ma2_ter_7 = Hour::find(235);
$ma2_ter_9 = Hour::find(236);
$ma2_qua_7 = Hour::find(237);
$ma2_qua_9 = Hour::find(238);
$ma2_qua_11 = Hour::find(239);
$ma2_qui_7 = Hour::find(240);
$ma2_qui_9 = Hour::find(241);
$ma2_qui_11 = Hour::find(242);
$ma2_sex_7 = Hour::find(243);
$ma2_sex_9 = Hour::find(244);
$ma2_sex_11 = Hour::find(245);

// ma 3 semestre
$ma3_seg_7 = Hour::find(246);
$ma3_seg_9 = Hour::find(247);
$ma3_seg_11 = Hour::find(248);
$ma3_ter_9 = Hour::find(249);
$ma3_ter_11 = Hour::find(250);
$ma3_qua_7 = Hour::find(251);
$ma3_qua_9 = Hour::find(252);
$ma3_qua_11 = Hour::find(253);
$ma3_qui_7 = Hour::find(254);
$ma3_qui_9 = Hour::find(255);
$ma3_sex_9 = Hour::find(256);
$ma3_sex_11 = Hour::find(257);

// ma 4 semestre
$ma4_seg_7 = Hour::find(258);
$ma4_seg_9 = Hour::find(259);
$ma4_seg_11 = Hour::find(260);
$ma4_ter_7 = Hour::find(261);
$ma4_ter_9 = Hour::find(262);
$ma4_qua_7 = Hour::find(263);
$ma4_qua_9 = Hour::find(264);
$ma4_qui_7 = Hour::find(265);
$ma4_qui_9 = Hour::find(266);
$ma4_qui_11 = Hour::find(267);
$ma4_sex_9 = Hour::find(268);
$ma4_sex_11 = Hour::find(269);


return view('pages.grade',
compact(
// dsm 1 e 2 semestre
Expand Down Expand Up @@ -259,6 +389,45 @@ public function show_dsm()
'cn6_seg_7','cn6_seg_9','cn6_ter_7','cn6_ter_9','cn6_ter_11','cn6_qua_7',
'cn6_qua_9','cn6_qui_7','cn6_qui_9','cn6_sex_7','cn6_sex_9','cn6_sex_11',

// gpi 1 semestre
'gp1_seg_7','gp1_seg_9','gp1_ter_7','gp1_ter_9','gp1_qua_7','gp1_qua_9',
'gp1_qui_7','gp1_qui_9','gp1_sex_7','gp1_sex_9',

// gpi 2 semestre
'gp2_seg_7','gp2_seg_9','gp2_ter_7','gp2_ter_9','gp2_qua_7','gp2_qua_9',
'gp2_qui_7','gp2_qui_9','gp2_sex_7','gp2_sex_9',

// gpi 3 semestre
'gp3_seg_7','gp3_seg_9','gp3_ter_7','gp3_ter_9','gp3_qua_7','gp3_qua_9',
'gp3_qui_7','gp3_qui_9','gp3_sex_7','gp3_sex_9',

// gpi 4 semestre
'gp4_seg_7','gp4_seg_9','gp4_ter_7','gp4_ter_9','gp4_qua_7','gp4_qua_9',
'gp4_qui_7','gp4_qui_9','gp4_sex_7','gp4_sex_9',

// gpi 5 semestre
'gp5_seg_7','gp5_seg_9','gp5_ter_7','gp5_ter_9','gp5_qua_7','gp5_qua_9',
'gp5_qui_7','gp5_qui_9','gp5_sex_7','gp5_sex_9',

// gpi 6 semestre
'gp6_seg_7','gp6_seg_9','gp6_ter_7','gp6_ter_9','gp6_qua_7','gp6_qua_9',
'gp6_qui_7','gp6_qui_9','gp6_sex_7','gp6_sex_9',

// ma 1 semestre
'ma1_seg_7','ma1_seg_9','ma1_ter_7','ma1_ter_9','ma1_qua_7','ma1_qua_9',
'ma1_qui_7','ma1_qui_9','ma1_sex_7','ma1_sex_9','ma1_sab_7','ma1_sab_9',

// ma 2 semestre
'ma2_seg_7','ma2_seg_9','ma2_ter_7','ma2_ter_9','ma2_qua_7','ma2_qua_9',
'ma2_qui_7','ma2_qui_9','ma2_qui_11','ma2_sex_7','ma2_sex_9','ma2_sex_11',

// ma 3 semestre
'ma3_seg_7','ma3_seg_9','ma3_seg_11','ma3_ter_9','ma3_ter_11','ma3_qua_7',
'ma3_qua_9','ma3_qua_11','ma3_qui_7','ma3_qui_9','ma3_sex_9','ma3_sex_11',

// ma 4 semestre
'ma4_seg_7','ma4_seg_9','ma4_seg_11','ma4_ter_7','ma4_ter_9','ma4_qua_7',
'ma4_qua_9','ma4_qui_7','ma4_qui_9','ma4_qui_11','ma4_sex_9','ma4_sex_11',
));
}
public function grade()
Expand All @@ -275,7 +444,7 @@ public function grade()

}

public function store(Request $request): RedirectResponse
public function store(Request $request)
{

//dd($request->all());
Expand All @@ -293,6 +462,7 @@ public function store(Request $request): RedirectResponse
'dia'=>$request->days,
'hora'=>$request->hours]);

return redirect()->route('fazer')->with('status','hour-created');
return response()->json(['success' => true]);
//return redirect()->route('dash')->with('status','hour-created');
}
}
4 changes: 0 additions & 4 deletions app/Http/Controllers/IntegraController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ public function create()
// 'name'=>'Sala 302',
// 'block_id'=>5
//]);

$hour = Hour::find(7);
$hour->user_id = 5;
$hour->save();
}

/**
Expand Down
25 changes: 25 additions & 0 deletions app/Http/Middleware/CheckAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;

class CheckAdmin
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
if(Auth::check() && Auth::user()->role === 'admin'){
return $next($request);
}

return redirect('/')->with('error','Você não tem permissão para acessar essa página!');
}
}
3 changes: 1 addition & 2 deletions public/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
width: 50%;
height: 2rem;
}
.admin-right-all-container {
.admin-right-all-container, .text-wel {
padding: 40px;
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -96,7 +96,6 @@
border: 1px solid var(--dsm-border-color-tertiary);
color: var(--dsm-font-color-quaternary);
}

/* TELA MINHAS PUBLICACOES */

@media(min-width: 576px) {
Expand Down
8 changes: 6 additions & 2 deletions public/css/horario_2.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
margin-bottom: 1rem;
}
.dsm-s1, .dsm-s2,.sn-s1,.sn-s2, .sn-s3, .sn-s4, .sn-s5, .sn-s6
,.cn-s1,.cn-s2,.cn-s3,.cn-s4,.cn-s5,.cn-s6{
,.cn-s1,.cn-s2,.cn-s3,.cn-s4,.cn-s5,.cn-s6,.gp-s1,.gp-s2,.gp-s3,
.gp-s4,.gp-s5,.gp-s6,.ma-s1,.ma-s2,.ma-s3,.ma-s4,.ma-s5,.ma-s6{
display: inline-block;
padding: 1rem;
border: 1px solid red;
Expand All @@ -29,11 +30,14 @@
background-color: crimson;
color: lightcyan;
border-radius: 15px;
margin-right: 0.5rem;
}
.dsm-s1:hover,.dsm-s2:hover,.sn-s1:hover,
.sn-s2:hover,.sn-s3:hover,.sn-s4:hover,.sn-s5:hover,.sn-s6:hover,
.cn-s1:hover,.cn-s2:hover,.cn-s3:hover,.cn-s4:hover,.cn-s5:hover,
.cn-s6:hover{
.cn-s6:hover,.gp-s1:hover,.gp-s2:hover,.gp-s3:hover,.gp-s4:hover,
.gp-s5:hover,.gp-s6:hover,.ma-s1:hover,.ma-s2:hover,.ma-s3:hover,
.ma-s4:hover,.ma-s5:hover,.ma-s6:hover{
background-color: coral;
}

Expand Down
Binary file added public/img/lapis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bd7a397

Please sign in to comment.