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
5f9ce747
Commit
5f9ce747
authored
Jun 12, 2020
by
alinetenorio
Browse files
adicionar participante ao editar projeto
parent
5af65369
Changes
1
Show whitespace changes
Inline
Side-by-side
app/Http/Controllers/TrabalhoController.php
View file @
5f9ce747
...
...
@@ -441,6 +441,8 @@ class TrabalhoController extends Controller
foreach
(
$request
->
emailParticipante
as
$key
=>
$value
)
{
// criando novos participantes que podem ter sido adicionados
if
(
!
(
in_array
(
$request
->
emailParticipante
[
$key
],
$emailParticipantes
,
false
)))
{
$userParticipante
=
User
::
where
(
'email'
,
$value
)
->
first
();
if
(
$userParticipante
==
null
){
$passwordTemporario
=
Str
::
random
(
8
);
Mail
::
to
(
$value
)
->
send
(
new
EmailParaUsuarioNaoCadastrado
(
Auth
()
->
user
()
->
name
,
' '
,
'Participante'
,
$evento
->
nome
,
$passwordTemporario
));
$usuario
=
User
::
create
([
...
...
@@ -457,6 +459,21 @@ class TrabalhoController extends Controller
$participante
->
funcao_participante_id
=
$request
->
funcaoParticipante
[
$key
];
$participante
->
save
();
}
else
{
$participante
=
new
Participante
();
$participante
->
user_id
=
$userParticipante
->
id
;
$participante
->
trabalho_id
=
$trabalho
->
id
;
$participante
->
funcao_participante_id
=
$request
->
funcaoParticipante
[
$key
];
$participante
->
save
();
$participante
->
trabalhos
()
->
save
(
$trabalho
);
$subject
=
"Participante de Projeto"
;
$email
=
$value
;
Mail
::
to
(
$email
)
->
send
(
new
SubmissaoTrabalho
(
$userParticipante
,
$subject
));
}
$path
=
'trabalhos/'
.
$request
->
editalId
.
'/'
.
$trabalho
->
id
.
'/'
;
$nome
=
$request
->
nomePlanoTrabalho
[
$key
]
.
".pdf"
;
$file
=
$request
->
anexoPlanoTrabalho
[
$key
];
...
...
@@ -474,6 +491,9 @@ class TrabalhoController extends Controller
//atualizando os participantes que já estão no projeto e planos de trabalho se enviados
if
(
in_array
(
$request
->
emailParticipante
[
$key
],
$emailParticipantes
,
false
))
{
$userParticipante
=
User
::
where
(
'email'
,
$value
)
->
first
();
//dd($userParticipante);
if
(
$userParticipante
!=
null
){
$user
=
User
::
where
(
'email'
,
$request
->
emailParticipante
[
$key
])
->
first
();
$participante
=
Participante
::
where
([[
'user_id'
,
'='
,
$user
->
id
],
[
'trabalho_id'
,
'='
,
$trabalho
->
id
]])
->
first
();
...
...
@@ -507,12 +527,14 @@ class TrabalhoController extends Controller
}
}
}
}
// Atualizando possiveis usuários removidos
$participantesUsersIds
=
Participante
::
where
(
'trabalho_id'
,
'='
,
$trabalho
->
id
)
->
select
(
'user_id'
)
->
get
();
$users
=
User
::
whereIn
(
'id'
,
$participantesUsersIds
)
->
get
();
foreach
(
$users
as
$user
)
{
//dd($user);
if
(
!
(
in_array
(
$user
->
email
,
$request
->
emailParticipante
,
false
)))
{
$participante
=
Participante
::
where
([[
'user_id'
,
'='
,
$user
->
id
],
[
'trabalho_id'
,
'='
,
$trabalho
->
id
]])
->
first
();
$arquivo
=
Arquivo
::
where
(
'participanteId'
,
$participante
->
id
);
...
...
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