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
cae7206d
Commit
cae7206d
authored
Mar 16, 2022
by
Guilherme Silva
Browse files
Ajuste da função de confirmação de leitura da notificação
parent
0500e1bd
Changes
1
Show whitespace changes
Inline
Side-by-side
app/Http/Controllers/NotificacaoController.php
View file @
cae7206d
...
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
...
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use
App\Notificacao
;
use
App\Notificacao
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
class
NotificacaoController
extends
Controller
class
NotificacaoController
extends
Controller
{
{
...
@@ -86,14 +87,46 @@ class NotificacaoController extends Controller
...
@@ -86,14 +87,46 @@ class NotificacaoController extends Controller
public
function
listar
()
public
function
listar
()
{
{
$notificacoes
=
Notificacao
::
all
()
->
sortByDesc
(
'created_at'
);
$notificacoes
=
Notificacao
::
all
()
->
sortByDesc
(
'created_at'
);
return
view
(
'notificacao.listar'
,[
'notificacoes'
=>
$notificacoes
]);
return
view
(
'notificacao.listar'
,
[
'notificacoes'
=>
$notificacoes
]);
}
}
public
function
listarTrab
()
public
function
listarTrab
()
{
{
$destinatarios
=
Notificacao
::
where
(
'destinatario_id'
,
Auth
()
->
user
()
->
id
)
->
get
();
$notificacoes
=
Notificacao
::
where
(
'destinatario_id'
,
Auth
()
->
user
()
->
id
)
->
get
()
->
sortByDesc
(
'created_at'
);
$remetentes
=
Notificacao
::
where
(
'remetente_id'
,
Auth
()
->
user
()
->
id
)
->
get
();
$notificacoes
=
$destinatarios
->
merge
(
$remetentes
)
->
sortByDesc
(
'created_at'
);
return
view
(
'notificacao.listar'
,
[
'notificacoes'
=>
$notificacoes
]);
return
view
(
'notificacao.listar'
,[
'notificacoes'
=>
$notificacoes
]);
}
public
function
ler
(
$id
)
{
$notificacao
=
Notificacao
::
find
(
$id
);
if
(
!
$notificacao
->
lido
)
{
$notificacao
->
lido
=
true
;
$notificacao
->
update
();
}
if
(
$notificacao
->
tipo
==
1
)
{
if
(
$notificacao
->
destinatario_id
==
Auth
()
->
user
()
->
id
&&
Auth
()
->
user
()
->
tipo
!=
'proponente'
)
{
return
redirect
()
->
route
(
'admin.analisarProposta'
,
[
'id'
=>
$notificacao
->
trabalho
->
id
]);
}
else
{
return
redirect
()
->
route
(
'trabalho.show'
,
[
'id'
=>
$notificacao
->
trabalho
->
id
]);
}
}
elseif
(
$notificacao
->
tipo
==
2
)
{
if
(
$notificacao
->
destinatario_id
==
Auth
()
->
user
()
->
id
&&
Auth
()
->
user
()
->
tipo
!=
'proponente'
)
{
return
redirect
()
->
route
(
'admin.analisarProposta'
,
[
'id'
=>
$notificacao
->
trabalho
->
id
]);
}
else
{
return
redirect
()
->
route
(
'trabalho.trocaParticipante'
,
[
'evento_id'
=>
$notificacao
->
trabalho
->
evento
->
id
,
'projeto_id'
=>
$notificacao
->
trabalho
->
id
]);
}
}
}
elseif
(
$notificacao
->
tipo
==
3
||
$notificacao
->
tipo
==
4
)
{
return
redirect
()
->
route
(
'planos.listar'
,
[
'id'
=>
$notificacao
->
trabalho
->
id
]);
}
elseif
(
$notificacao
->
tipo
==
5
)
{
if
(
!
is_null
(
Auth
::
user
()
->
avaliadors
->
eventos
->
where
(
'id'
,
$notificacao
->
trabalho
->
evento
->
id
)
->
first
()
->
pivot
->
convite
)
&&
Auth
::
user
()
->
avaliadors
->
eventos
->
where
(
'id'
,
$notificacao
->
trabalho
->
evento
->
id
)
->
first
()
->
pivot
->
convite
==
true
)
{
return
redirect
()
->
route
(
'avaliador.visualizarTrabalho'
,
[
'evento_id'
=>
$notificacao
->
trabalho
->
evento
->
id
]);
}
else
{
return
redirect
()
->
route
(
'avaliador.editais'
);
}
}
}
}
}
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