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
submeta
Commits
407861f5
Commit
407861f5
authored
May 27, 2020
by
Gabriel-31415
Browse files
add relacao avaliador e trabalho
parent
46255a60
Changes
33
Hide whitespace changes
Inline
Side-by-side
app/Avaliador.php
View file @
407861f5
...
...
@@ -9,4 +9,7 @@ class Avaliador extends Model
public
function
user
(){
return
$this
->
belongsTo
(
'App\User'
);
}
public
function
trabalhos
(){
return
$this
->
belongsToMany
(
'App\Trabalho'
);
}
}
app/CoordenadorComissao.php
View file @
407861f5
...
...
@@ -11,7 +11,7 @@ class CoordenadorComissao extends Model
}
public
function
editais
(){
return
$this
->
hasMany
(
'App\Evento'
,
'coordenadorId'
);
return
$this
->
hasMany
(
'App\Evento'
);
}
public
function
trabalho
(){
...
...
app/Evento.php
View file @
407861f5
...
...
@@ -15,7 +15,7 @@ class Evento extends Model
'nome'
,
'descricao'
,
'tipo'
,
'inicioSubmissao'
,
'fimSubmissao'
,
'inicioRevisao'
,
'fimRevisao'
,
'resultado'
,
'coordenadorId'
,
'numMaxTrabalhos'
,
'numMaxCoautores'
,
'hasResumo'
,
'numMaxTrabalhos'
,
'numMaxCoautores'
,
'hasResumo'
,
'criador_id'
];
public
function
endereco
(){
...
...
app/Http/Controllers/AdministradorController.php
View file @
407861f5
...
...
@@ -3,6 +3,8 @@
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
use
App\Administrador
;
use
App\Evento
;
class
AdministradorController
extends
Controller
{
...
...
@@ -18,4 +20,12 @@ class AdministradorController extends Controller
return
view
(
'administrador.usuarios'
);
}
public
function
editais
(){
//$admin = Administrador::with('user')->where('user_id', Auth()->user()->id)->first();
//$eventos = Evento::where('coordenadorId',$admin->id )->get();
$eventos
=
Evento
::
where
(
'criador_id'
,
Auth
()
->
user
()
->
id
)
->
get
();
return
view
(
'administrador.editais'
,
[
'eventos'
=>
$eventos
]);
}
}
app/Http/Controllers/AdministradorResponsavelController.php
0 → 100644
View file @
407861f5
<?php
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
use
App\AdministradorResponsavel
;
use
App\User
;
use
App\Evento
;
use
App\Avaliador
;
class
AdministradorResponsavelController
extends
Controller
{
public
function
index
(){
return
view
(
'administradorResponsavel.index'
);
}
public
function
editais
(){
//$admResponsavel = AdministradorResponsavel::with('user')->where('user_id', Auth()->user()->id)->first();
$eventos
=
Evento
::
where
(
'criador_id'
,
Auth
()
->
user
()
->
id
)
->
get
();
return
view
(
'administradorResponsavel.editais'
,
[
'eventos'
=>
$eventos
]);
}
public
function
usuarios
(){
return
view
(
'administradorResponsavel.usuarios'
);
}
public
function
atribuirPermissao
(
Request
$request
){
$user
=
User
::
where
(
'id'
,
$request
->
user_id
)
->
first
();
$isAvaliador
=
Avaliador
::
where
(
'user_id'
,
$request
->
user_id
)
->
count
();
$avaliador
=
new
Avaliador
();
$avaliador
->
save
();
if
(
$isAvaliador
==
0
){
//$user->avaliadors()->save($user);
$avaliador
->
user
()
->
associate
(
$user
);
// um avaliador tem um usuario
$avaliador
->
save
();
//$user->avaliadors()->save($avaliador); //um usuario pode ter muitos avaliadores
//$user->save();
//$avaliador->user_id = $user->id;
$success
=
true
;
}
else
{
$avaliador
=
Avaliador
::
where
(
'user_id'
,
$request
->
user_id
)
->
first
();
$avaliador
->
user
()
->
dissociate
(
$user
);
// um avaliador tem um usuario
$avaliador
->
save
();
$success
=
false
;
}
return
response
()
->
json
(
$success
);
}
public
function
verPermissao
(
Request
$request
){
$user
=
User
::
where
(
'id'
,
$request
->
user_id
)
->
first
();
$isAvaliador
=
Avaliador
::
where
(
'user_id'
,
$request
->
user_id
)
->
count
();
if
(
$isAvaliador
!=
0
){
$success
=
true
;
}
else
{
$success
=
false
;
}
return
response
()
->
json
(
[
$success
]
);
//return response()->json( $request->user_id );
}
}
app/Http/Controllers/CoordenadorComissaoController.php
View file @
407861f5
...
...
@@ -24,8 +24,8 @@ class CoordenadorComissaoController extends Controller
public
function
editais
(){
$eventos
=
Evento
::
where
(
'coordenadorId'
,
Auth
()
->
user
()
->
id
)
->
get
();
$coordenador
=
CoordenadorComissao
::
with
(
'user'
)
->
where
(
'user_id'
,
Auth
()
->
user
()
->
id
)
->
first
();
$eventos
=
Evento
::
where
(
'coordenadorId'
,
$coordenador
->
id
)
->
get
();
return
view
(
'coordenadorComissao.editais'
,
[
'eventos'
=>
$eventos
]);
...
...
app/Http/Controllers/EventoController.php
View file @
407861f5
...
...
@@ -72,8 +72,10 @@ class EventoController extends Controller
$mytime
=
Carbon
::
now
(
'America/Recife'
);
$yesterday
=
Carbon
::
yesterday
(
'America/Recife'
);
$yesterday
=
$yesterday
->
toDateString
();
//$admResponsavel = AdministradorResponsavel::with('user')->where('user_id', Auth()->user()->id)->first();
$user_id
=
Auth
()
->
user
()
->
id
;
//dd($
request
);
//dd($
user_id
);
// validar datas nulas antes, pois pode gerar um bug
if
(
...
...
@@ -123,8 +125,9 @@ class EventoController extends Controller
'fimRevisao'
=>
$request
->
fimRevisao
,
'resultado'
=>
$request
->
resultado
,
'coordenadorId'
=>
$request
->
coordenador_id
,
'criador_id'
=>
$user_id
,
]);
//dd($evento);
// $user = User::find($request->coordenador_id);
// $user->coordenadorComissao()->editais()->save($evento);
...
...
app/Http/Controllers/TrabalhoController.php
View file @
407861f5
...
...
@@ -187,6 +187,7 @@ class TrabalhoController extends Controller
'password'
=>
bcrypt
(
$passwordTemporario
),
'usuarioTemp'
=>
true
,
'name'
=>
$request
->
nomeParticipante
[
$key
],
'tipo'
=>
'participante'
,
'funcao_participante_id'
=>
$request
->
funcaoParticipante
[
$key
],
]);
...
...
app/Http/Controllers/UserController.php
View file @
407861f5
...
...
@@ -10,6 +10,7 @@ use App\Endereco;
use
App\Trabalho
;
use
App\Coautor
;
use
App\Evento
;
use
App\Proponente
;
use
Illuminate\Support\Facades\Log
;
class
UserController
extends
Controller
...
...
@@ -108,9 +109,13 @@ class UserController extends Controller
public
function
meusTrabalhos
(){
$trabalhos
=
Trabalho
::
where
(
'autorId'
,
Auth
::
user
()
->
id
)
->
get
();
//$trabalhos = Trabalho::where('autorId', Auth::user()->id)->get();
$proponente
=
Proponente
::
with
(
'user'
)
->
where
(
'user_id'
,
Auth
::
user
()
->
id
)
->
first
();
$trabalhos
=
$proponente
->
trabalhos
;
//dd($trabalhos);
return
view
(
'user.meusTrabalhos'
,[
'trabalhos'
=>
$trabalhos
,
'trabalhos'
=>
$trabalhos
,
]);
}
}
app/Policies/EventoPolicy.php
View file @
407861f5
...
...
@@ -4,6 +4,8 @@ namespace App\Policies;
use
App\User
;
use
App\Evento
;
use
App\CoordenadorComissao
;
use
App\AdministradorResponsavel
;
use
Illuminate\Auth\Access\HandlesAuthorization
;
class
EventoPolicy
...
...
@@ -21,6 +23,9 @@ class EventoPolicy
}
public
function
isCoordenador
(
User
$user
,
Evento
$evento
){
return
$user
->
id
===
$evento
->
coordenador
->
id
;
return
$evento
->
criador_id
==
Auth
()
->
user
()
->
id
;
}
}
app/Trabalho.php
View file @
407861f5
...
...
@@ -81,4 +81,7 @@ class Trabalho extends Model
public
function
coordenador
(){
return
$this
->
belongsTo
(
'App\CoordenadorComissao'
);
}
public
function
avaliadors
(){
return
$this
->
belongsToMany
(
'App\Avaliador'
);
}
}
app/User.php
View file @
407861f5
...
...
@@ -20,7 +20,7 @@ class User extends Authenticatable implements MustVerifyEmail
protected
$fillable
=
[
'name'
,
'email'
,
'password'
,
'cpf'
,
'instituicao'
,
'celular'
,
'especProfissional'
,
'enderecoId'
,
'usuarioTemp'
,
'usuarioTemp'
,
'tipo'
,
'user_id'
];
/**
...
...
@@ -79,7 +79,7 @@ class User extends Authenticatable implements MustVerifyEmail
public
function
administradors
(){
return
$this
->
hasMany
(
'App\Administrador'
);
}
public
function
P
roponentes
(){
public
function
p
roponentes
(){
return
$this
->
hasMany
(
'App\Proponente'
);
}
public
function
AdministradorResponsavel
(){
...
...
database/migrations/2020_02_05_123153_create_eventos_table.php
View file @
407861f5
...
...
@@ -27,7 +27,7 @@ class CreateEventosTable extends Migration
$table
->
integer
(
'numMaxTrabalhos'
)
->
nullable
();
$table
->
integer
(
'numMaxCoautores'
)
->
nullable
();
$table
->
boolean
(
'hasResumo'
)
->
nullable
();
$table
->
integer
(
'c
oordComissaoI
d'
)
->
nullable
();
$table
->
integer
(
'c
riador_i
d'
)
->
nullable
();
$table
->
integer
(
'coordenadorId'
)
->
nullable
();
$table
->
string
(
'pdfEdital'
)
->
nullable
();
$table
->
string
(
'modeloDocumento'
)
->
nullable
();
...
...
database/migrations/2020_02_06_132418_chaves_estrangeiras.php
View file @
407861f5
...
...
@@ -131,9 +131,9 @@ class ChavesEstrangeiras extends Migration
// Schema::table('revisors', function (Blueprint $table) {
// $table->foreign('areaId')->references('id')->on('areas');
// });
Schema
::
table
(
'eventos'
,
function
(
Blueprint
$table
){
$table
->
foreign
(
'coordComissaoId'
)
->
references
(
'id'
)
->
on
(
'users'
);
});
//
Schema::table('eventos',function (Blueprint $table){
//
$table->foreign('coordComissaoId')->references('id')->on('users');
//
});
//------------------------------------------------------------------------
}
...
...
database/migrations/2020_05_23_054805_create_avaliadors_table.php
View file @
407861f5
...
...
@@ -17,7 +17,7 @@ class CreateAvaliadorsTable extends Migration
$table
->
bigIncrements
(
'id'
);
$table
->
timestamps
();
$table
->
unsignedBigInteger
(
'user_id'
);
$table
->
unsignedBigInteger
(
'user_id'
)
->
nullable
()
;
$table
->
foreign
(
'user_id'
)
->
references
(
'id'
)
->
on
(
'users'
);
});
}
...
...
database/migrations/2020_05_26_223341_create_avaliadors_trabalhos_table.php
0 → 100644
View file @
407861f5
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateAvaliadorsTrabalhosTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'avaliador_trabalho'
,
function
(
Blueprint
$table
)
{
$table
->
unsignedBigInteger
(
'trabalho_id'
);
$table
->
unsignedBigInteger
(
'avaliador_id'
);
$table
->
foreign
(
'trabalho_id'
)
->
references
(
'id'
)
->
on
(
'trabalhos'
);
$table
->
foreign
(
'avaliador_id'
)
->
references
(
'id'
)
->
on
(
'avaliadors'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'avaliador_trabalho'
);
}
}
database/seeds/AdministradorResponsavelSeeder.php
View file @
407861f5
...
...
@@ -12,11 +12,18 @@ class AdministradorResponsavelSeeder extends Seeder
*/
public
function
run
()
{
$user_id
=
DB
::
table
(
'users'
)
->
where
(
'name'
,
'AdministradorResponsavel'
)
->
pluck
(
'id'
);
$user_id
=
DB
::
table
(
'users'
)
->
where
(
'name'
,
'AdministradorResponsavel
1
'
)
->
pluck
(
'id'
);
DB
::
table
(
'administrador_responsavels'
)
->
insert
([
'user_id'
=>
$user_id
[
0
],
]);
$user_id
=
DB
::
table
(
'users'
)
->
where
(
'name'
,
'AdministradorResponsavel2'
)
->
pluck
(
'id'
);
DB
::
table
(
'administrador_responsavels'
)
->
insert
([
'user_id'
=>
$user_id
[
0
],
]);
}
}
database/seeds/DatabaseSeeder.php
View file @
407861f5
...
...
@@ -21,6 +21,7 @@ class DatabaseSeeder extends Seeder
$this
->
call
(
SubAreaSeeder
::
class
);
$this
->
call
(
FuncaoParticipanteSeeder
::
class
);
$this
->
call
(
CoordenadorComissaoSeeder
::
class
);
$this
->
call
(
ParticipanteSeeder
::
class
);
// $this->call(UsersTableSeeder::class);
// DB::table('enderecos')->insert([ // 1
...
...
@@ -65,6 +66,24 @@ class DatabaseSeeder extends Seeder
// 'email_verified_at' => '2020-02-15',
// ]);
DB
::
table
(
'eventos'
)
->
insert
([
'nome'
=>
'I CONGRESSO REGIONAL DE ZOOTECNIA'
,
// 'numeroParticipantes'=>60,
'descricao'
=>
'Cada autor inscrito poderá submeter até dois (2) resumos;
O número máximo de autores por trabalho será seis autores;
Os trabalhos deverão ser submetidos na forma de resumo simples com no máximo uma (01) página, no formato PDF;'
,
'tipo'
=>
'PIBIC'
,
'inicioSubmissao'
=>
'2020-03-30'
,
'fimSubmissao'
=>
'2020-09-20'
,
'inicioRevisao'
=>
'2020-04-21'
,
'fimRevisao'
=>
'2020-05-21'
,
'resultado'
=>
'2020-05-22'
,
'numMaxTrabalhos'
=>
2
,
'numMaxCoautores'
=>
5
,
'coordenadorId'
=>
1
,
'criador_id'
=>
1
,
]);
DB
::
table
(
'eventos'
)
->
insert
([
'nome'
=>
'II CONGRESSO REGIONAL DE ZOOTECNIA'
,
// 'numeroParticipantes'=>60,
...
...
@@ -80,6 +99,25 @@ class DatabaseSeeder extends Seeder
'numMaxTrabalhos'
=>
2
,
'numMaxCoautores'
=>
5
,
'coordenadorId'
=>
1
,
'criador_id'
=>
2
,
]);
DB
::
table
(
'eventos'
)
->
insert
([
'nome'
=>
'III CONGRESSO REGIONAL DE ZOOTECNIA'
,
// 'numeroParticipantes'=>60,
'descricao'
=>
'Cada autor inscrito poderá submeter até dois (2) resumos;
O número máximo de autores por trabalho será seis autores;
Os trabalhos deverão ser submetidos na forma de resumo simples com no máximo uma (01) página, no formato PDF;'
,
'tipo'
=>
'PIBIC'
,
'inicioSubmissao'
=>
'2020-03-30'
,
'fimSubmissao'
=>
'2020-09-20'
,
'inicioRevisao'
=>
'2020-04-21'
,
'fimRevisao'
=>
'2020-05-21'
,
'resultado'
=>
'2020-05-22'
,
'numMaxTrabalhos'
=>
2
,
'numMaxCoautores'
=>
5
,
'coordenadorId'
=>
1
,
'criador_id'
=>
3
,
]);
// $areasEventoZoo = [
...
...
database/seeds/ParticipanteSeeder.php
0 → 100644
View file @
407861f5
<?php
use
Illuminate\Database\Seeder
;
class
ParticipanteSeeder
extends
Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public
function
run
()
{
$user_id
=
DB
::
table
(
'users'
)
->
where
(
'name'
,
'Participante1'
)
->
pluck
(
'id'
);
DB
::
table
(
'participantes'
)
->
insert
([
'user_id'
=>
$user_id
[
0
],
]);
$user_id
=
DB
::
table
(
'users'
)
->
where
(
'name'
,
'Participante2'
)
->
pluck
(
'id'
);
DB
::
table
(
'participantes'
)
->
insert
([
'user_id'
=>
$user_id
[
0
],
]);
}
}
database/seeds/UsuarioSeeder.php
View file @
407861f5
...
...
@@ -24,8 +24,16 @@ class UsuarioSeeder extends Seeder
DB
::
table
(
'users'
)
->
insert
([
'name'
=>
'AdministradorResponsavel'
,
'email'
=>
'adminResp@ufrpe.br'
,
'name'
=>
'AdministradorResponsavel1'
,
'email'
=>
'adminResp1@ufrpe.br'
,
'password'
=>
Hash
::
make
(
'12345678'
),
'tipo'
=>
'administradorResponsavel'
,
'email_verified_at'
=>
'2020-01-01'
]);
DB
::
table
(
'users'
)
->
insert
([
'name'
=>
'AdministradorResponsavel2'
,
'email'
=>
'adminResp2@ufrpe.br'
,
'password'
=>
Hash
::
make
(
'12345678'
),
'tipo'
=>
'administradorResponsavel'
,
'email_verified_at'
=>
'2020-01-01'
...
...
@@ -57,5 +65,24 @@ class UsuarioSeeder extends Seeder
'tipo'
=>
'coordenador'
,
'email_verified_at'
=>
'2020-01-01'
]);
DB
::
table
(
'users'
)
->
insert
([
'name'
=>
'Participante1'
,
'email'
=>
'part1@ufrpe.br'
,
'password'
=>
Hash
::
make
(
'12345678'
),
'tipo'
=>
'participante'
,
'email_verified_at'
=>
'2020-01-01'
]);
DB
::
table
(
'users'
)
->
insert
([
'name'
=>
'Participante2'
,
'email'
=>
'part2@ufrpe.br'
,
'password'
=>
Hash
::
make
(
'12345678'
),
'tipo'
=>
'participante'
,
'email_verified_at'
=>
'2020-01-01'
]);
}
}
Prev
1
2
Next
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