Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Walter Felipe
pad-upe
Commits
8920b61e
Commit
8920b61e
authored
Mar 26, 2023
by
Gabriel
Browse files
adicionando migrations e telas para implementar lógica de avaliador
parent
523dc609
Changes
10
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/PadController.php
View file @
8920b61e
<?php
namespace
App\Http\Controllers
;
use
App\Http\Controllers\Controller
;
use
Illuminate\Http\Request
;
use
App\Models\Pad
;
...
...
@@ -53,7 +53,7 @@ class PadController extends Controller
* @return \Illuminate\View\View
*/
public
function
index
()
{
{
if
(
Auth
::
user
()
->
isTypeAdmin
())
{
$users
=
User
::
initQuery
()
->
whereType
(
UserType
::
TEACHER
)
->
get
();
...
...
@@ -61,7 +61,7 @@ class PadController extends Controller
$menu
=
Menu
::
PADS
;
return
view
(
'pad.admin.index'
,
[
'menu'
=>
$menu
,
'pads'
=>
$pads
]);
}
if
(
Auth
::
user
()
->
isTypeTeacher
())
{
$menu
=
Menu
::
PADS
;
...
...
@@ -76,8 +76,8 @@ class PadController extends Controller
* @return \Illuminate\Http\Response
*/
public
function
view
(
$id
)
{
$ensinoTotalHoras
=
{
$ensinoTotalHoras
=
EnsinoAtendimentoDiscente
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
+
EnsinoAula
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
+
EnsinoCoordenacaoRegencia
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
...
...
@@ -87,8 +87,8 @@ class PadController extends Controller
+
EnsinoParticipacao
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
+
EnsinoProjeto
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
+
EnsinoSupervisao
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
);
$gestaoTotalHoras
=
$gestaoTotalHoras
=
GestaoCoordenacaoLaboratoriosDidaticos
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
+
GestaoCoordenacaoProgramaInstitucional
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
+
GestaoMembroCamaras
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
...
...
@@ -97,7 +97,7 @@ class PadController extends Controller
+
GestaoMembroTitularConselho
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
+
GestaoOutros
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
+
GestaoRepresentanteUnidadeEducacao
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
);
$pesquisaTotalHoras
=
PesquisaCoordenacao
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
+
PesquisaLideranca
::
whereUserPadId
(
$id
)
->
sum
(
'ch_semanal'
)
...
...
@@ -112,25 +112,25 @@ class PadController extends Controller
$menu
=
Menu
::
PADS
;
return
view
(
'pad.teacher.view'
,
[
'menu'
=>
$menu
,
'user_pad_id'
=>
$id
,
'user_pad_id'
=>
$id
,
'gestaoTotalHoras'
=>
$gestaoTotalHoras
,
'ensinoTotalHoras'
=>
$ensinoTotalHoras
,
'pesquisaTotalHoras'
=>
$pesquisaTotalHoras
,
'extensaoTotalHoras'
=>
$extensaoTotalHoras
,
]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public
function
create
()
{
{
$menu
=
Menu
::
PADS
;
$status
=
[
Status
::
ATIVO
=>
Status
::
listStatus
(
Status
::
ATIVO
)
Status
::
ATIVO
=>
Status
::
listStatus
(
Status
::
ATIVO
)
];
return
view
(
'pad.admin.create'
,
[
...
...
@@ -144,7 +144,7 @@ class PadController extends Controller
* @param \Illuminate\Http\Request $request
*/
public
function
store
(
Request
$request
)
{
{
$validated
=
$request
->
validate
([
'nome'
=>
[
'required'
,
'string'
,
'min:6'
,
'max:255'
],
'status'
=>
[
'required'
,
'integer'
],
...
...
@@ -164,13 +164,13 @@ class PadController extends Controller
$model
=
new
Pad
(
$request
->
all
());
$users
=
User
::
initQuery
()
->
whereType
(
UserType
::
TEACHER
)
->
get
();
if
(
$model
->
save
())
{
$users
=
User
::
initQuery
()
->
whereType
(
UserType
::
TEACHER
)
->
get
();
foreach
(
$users
as
$user
)
{
{
$profile
=
$user
->
profile
(
UserType
::
TEACHER
);
if
(
$profile
)
...
...
@@ -179,7 +179,7 @@ class PadController extends Controller
$userPad
->
pad_id
=
$model
->
id
;
$userPad
->
user_id
=
$user
->
id
;
$userPad
->
status
=
Status
::
ATIVO
;
$userPad
->
save
();
}
}
...
...
@@ -204,17 +204,21 @@ class PadController extends Controller
* @return \Illuminate\Http\Response
*/
public
function
edit
(
$id
)
{
{
$menu
=
Menu
::
PADS
;
$pad
=
PAD
::
find
(
$id
);
$userPads
=
$pad
->
userPads
;
$avaliatorsPads
=
$pad
->
avaliadorPads
;
$status
=
Constants
::
listStatus
();
return
view
(
'pad.admin.edit'
,
[
'pad'
=>
$pad
,
'menu'
=>
$menu
,
'status'
=>
$status
,
'userPads'
=>
$userPads
,
'avaliatorsPads'
=>
$avaliatorsPads
]);
}
...
...
@@ -226,7 +230,7 @@ class PadController extends Controller
* @return \Illuminate\Http\Response
*/
public
function
update
(
Request
$request
,
$id
)
{
{
$validated
=
$request
->
validate
([
'nome'
=>
[
'required'
,
'string'
,
'min:6'
,
'max:255'
],
'status'
=>
[
'required'
,
'integer'
],
...
...
@@ -244,7 +248,7 @@ class PadController extends Controller
if
(
$validated
)
{
$model
=
Pad
::
find
(
$id
);
$model
->
fill
(
$request
->
all
());
if
(
$model
->
save
())
{
return
redirect
()
->
route
(
'pad_index'
)
->
with
(
'success'
,
'PAD atualizado com sucesso!'
);
}
else
{
...
...
@@ -253,7 +257,7 @@ class PadController extends Controller
}
}
public
function
delete
(
$id
)
{
$model
=
Pad
::
find
(
$id
);
...
...
@@ -277,4 +281,4 @@ class PadController extends Controller
return
redirect
(
'/pad/index'
);
}
}
\ No newline at end of file
}
app/Models/AvaliadorPad.php
View file @
8920b61e
...
...
@@ -25,4 +25,13 @@ class AvaliadorPad extends Model
public
static
function
find
()
{
return
new
UserPadQuery
(
get_called_class
());
}
public
function
user
()
{
return
$this
->
belongsTo
(
User
::
class
);
}
public
function
dimensions
()
{
return
$this
->
hasMany
(
Dimension
::
class
);
}
}
app/Models/AvaliadorPadDimensao.php
0 → 100644
View file @
8920b61e
<?php
namespace
App\Models
;
use
Illuminate\Database\Eloquent\Model
;
class
AvaliadorPadDimensao
extends
Model
{
protected
$table
=
'avaliador_pad_dimensao'
;
protected
$fillable
=
[
'id'
,
'avaliador_pad_id'
,
'dimensao'
];
protected
$dates
=
[
'deleted_at'
];
public
function
avaliadorPad
()
{
return
$this
->
belongsTo
(
AvaliadorPad
::
class
);
}
}
app/Models/Pad.php
View file @
8920b61e
...
...
@@ -49,5 +49,13 @@ class Pad extends Model
public
function
userPads
()
{
return
$this
->
hasMany
(
UserPad
::
class
);
}
/**
* @return Illuminate\Database\Eloquent\Collection
* @return Collection<AvaliadorPad>
*/
public
function
avaliadorPads
(){
return
$this
->
hasMany
(
AvaliadorPad
::
class
);
}
}
database/migrations/2023_03_13_220732_alter_avaliador_pad_remove_dimensao_and_add_status_table.php
0 → 100644
View file @
8920b61e
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
AlterAvaliadorPadRemoveDimensaoAndAddStatusTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'avaliador_pad'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
(
'dimensao'
);
$table
->
tinyInteger
(
'status'
)
->
after
(
'pad_id'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'avaliador_pad'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
(
'status'
);
$table
->
tinyInteger
(
'dimensao'
)
->
after
(
'id'
);
});
}
}
database/migrations/2023_03_13_221712_create_avaliador_pad_dimensao_table.php
0 → 100644
View file @
8920b61e
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateAvaliadorPadDimensaoTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'avaliador_pad_dimensao'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
foreignId
(
'avaliador_pad_id'
)
->
constrained
(
'avaliador_pad'
);
$table
->
tinyInteger
(
'dimensao'
);
$table
->
softDeletes
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'avaliador_pad_dimensao'
);
}
}
resources/views/avaliador-pad/_form.blade.php
0 → 100644
View file @
8920b61e
@
php
function
field_validate
(
$field
)
{
$type_form
=
'create_and_update'
;
return
sprintf
(
"%s_%s"
,
$type_form
,
$field
);
}
@
endphp
<
div
class
=
"row"
>
<
input
type
=
"hidden"
name
=
"pad_id"
id
=
"pad_id"
value
=
"{{
$pad->id
}}"
>
<
div
class
=
"mb-3 col-sm-12"
>
<
label
class
=
"form-label"
for
=
"user_id"
>
Professor
</
label
>
<
select
class
=
"form-select @error('user_id') is-invalid @enderror ajax-errors"
name
=
"user_id"
id
=
"user_id"
>
<
option
value
=
"0"
>
Selecione
um
Professor
</
option
>
@
foreach
(
$users
as
$user
)
@
if
(
$user
->
id
==
$model
->
user_id
)
<
option
selected
value
=
"
{
{$user->id}}">{{$user->name}
}
</option>
@else
<option value="
{{
$user
->
id
}}
">
{
{$user->name}
}
</option>
@endif
@endforeach
</select>
@include('components.divs.errors', [
'field' => field_validate('user_id')
])
</div>
<div class="
mb
-
3
col
-
sm
-
6
">
<label class="
form
-
label
" for="
pad_name
"> PAD </label>
<input class="
form
-
control
" type="
text
" disabled value="
{{
$pad
->
nome
}}
">
</div>
<div class="
mb
-
3
col
-
sm
-
6
">
<label class="
form
-
label
" for="
status
">Status</label>
<select class="
form
-
select
@
error
(
'status'
)
is
-
invalid
@
enderror
ajax
-
errors
" name="
status
" id="
status
">
<option value="
0
">Selecione um Status</option>
@foreach(
$status
as
$value
=>
$stat
)
@if(
$value
==
$model->status
)
<option selected value="
{{
$value
}}
">
{
{$stat}
}
</option>
@else
<option value="
{{
$value
}}
">
{
{$stat}
}
</option>
@endif
@endforeach
</select>
@include('components.divs.errors', [
'field' => field_validate('nivel')
])
</div>
</div>
resources/views/avaliador-pad/create.blade.php
0 → 100644
View file @
8920b61e
<div
class=
"mb-3"
>
<h3
class=
"h3"
>
Cadastrar Professor (PAD)
</h3>
</div>
<form
id=
"form-user_pad"
action=
"{{ route('user-pad_store') }}"
method=
"post"
>
@csrf
@method('POST')
@include('user-pad._form', [
'pad' => $pad,
'model' => $model,
'users' => $users,
'status' => $status,
])
<div
class=
"mt-1 text-end"
>
<div
class=
"modal-footer"
>
@include('components.buttons.btn-save', [
'id' => 'btn_submit',
'content' => 'Cadastrar',
])
@include('components.buttons.btn-close_modal')
</div>
</div>
</form>
@include('pad.components.scripts.ajaxValidation', [
'btn_submit_id' => 'btn_submit',
'form_id' => 'form-user_pad',
'form_type' => 'create_and_update',
'route' => route('user-pad_ajax_validation'),
])
\ No newline at end of file
resources/views/avaliador-pad/update.blade.php
0 → 100644
View file @
8920b61e
resources/views/pad/admin/edit.blade.php
View file @
8920b61e
...
...
@@ -26,6 +26,9 @@
<
li
class
=
"nav-item"
role
=
"presentation"
>
<
button
class
=
"nav-link"
id
=
"user_pad-tab"
data
-
bs
-
toggle
=
"tab"
data
-
bs
-
target
=
"#user_pad-container"
type
=
"button"
role
=
"tab"
aria
-
controls
=
"user_pad-container"
arial
-
selected
=
"false"
>
Professores
</
button
>
</
li
>
<
li
class
=
"nav-item"
role
=
"presentation"
>
<
button
class
=
"nav-link"
id
=
"avaliator_pad-tab"
data
-
bs
-
toggle
=
"tab"
data
-
bs
-
target
=
"#avaliator_pad-container"
type
=
"button"
role
=
"tab"
aria
-
controls
=
"avaliator_pad-container"
arial
-
selected
=
"false"
>
Avaliadores
</
button
>
</
li
>
</
ul
>
</
div
>
...
...
@@ -84,7 +87,7 @@
</div>
@enderror
</div>
</div>
<div class="
mt
-
4
text
-
end
">
...
...
@@ -121,7 +124,7 @@
<th scope="
col
"> Opções </th>
</tr>
</thead>
<tbody>
@foreach(
$userPads
as
$userPad
)
<tr>
...
...
@@ -137,8 +140,51 @@
</div>
<div id="
avaliator_pad
-
container
" class="
tab
-
pane
fade
" role="
tabpanel
" aria-labelledby="
user_pad
-
tab
">
<div class="
border
rounded
px
-
2
">
<div class="
text
-
end
my
-
2
">
<button type="
button
" class="
btn
btn
-
success
valiator
-
pad
-
create
"> Cadastrar Avaliador </button>
</div>
<table id="
avaliator_pad
-
table
" class="
table
table
-
hover
">
<thead>
<tr>
<th scope="
col
"> Professor </th>
<th scope="
col
"> PAD </th>
<th scope="
col
"> Dimensão </th>
<th scope="
col
"> Opções </th>
</tr>
</thead>
<tbody>
@foreach(
$avaliatorsPads
as
$avaliatorPad
)
<tr>
<td>{{
$avaliatorPad->user
->name }}</td>
<td>{{
$avaliatorPad->pad
->nome }}</td>
<td>
{{-- @foreach(
$avaliatorPad->dimensions
as
$dimension
)
<span class="
badge
bg
-
primary
">{{
$dimension->nome
}}</span>
@endforeach --}}
</td>
<td>{{
$avaliatorPad->dimensao
}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
@include('components.modal', ['size' => 'modal-lg'])
@endsection
...
...
@@ -147,8 +193,13 @@
@include('pad.components.scripts.dimensao.ensino.show_modal', [
'modal_id' => 'modal',
'route' => route('user-pad_create', ['pad_id' =>
$pad->id
]),
'route' => route('user-pad_create', ['pad_id' =>
$pad->id
]),
'btn_class' => 'user-pad-create',
])
@endsection
\ No newline at end of file
@include('pad.components.scripts.dimensao.ensino.show_modal', [
'modal_id' => 'modal',
'route' => route('user-pad_create', ['pad_id' =>
$pad->id
]),
'btn_class' => 'valiator-pad-create',
])
@endsection
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment