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
545187d1
Commit
545187d1
authored
Jan 30, 2022
by
Guilherme Silva
Browse files
Adicionado notificação ao sistema
parent
e413fe86
Changes
3
Show whitespace changes
Inline
Side-by-side
app/Http/Controllers/NotificacaoController.php
0 → 100644
View file @
545187d1
<?php
namespace
App\Http\Controllers
;
use
App\Notificacao
;
use
Illuminate\Http\Request
;
class
NotificacaoController
extends
Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public
function
index
()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public
function
create
()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public
function
store
(
Request
$request
)
{
//
}
/**
* Display the specified resource.
*
* @param \App\Notificacao $notificacao
* @return \Illuminate\Http\Response
*/
public
function
show
(
Notificacao
$notificacao
)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Notificacao $notificacao
* @return \Illuminate\Http\Response
*/
public
function
edit
(
Notificacao
$notificacao
)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Notificacao $notificacao
* @return \Illuminate\Http\Response
*/
public
function
update
(
Request
$request
,
Notificacao
$notificacao
)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param \App\Notificacao $notificacao
* @return \Illuminate\Http\Response
*/
public
function
destroy
(
Notificacao
$notificacao
)
{
//
}
public
function
listar
()
{
$notificacoes
=
Notificacao
::
all
()
->
sortBy
(
'created_at'
);
return
view
(
'notificacao.listar'
,[
'notificacoes'
=>
$notificacoes
]);
}
public
function
listarTrab
()
{
$destinatarios
=
Notificacao
::
where
(
'destinatario_id'
,
Auth
()
->
user
()
->
id
)
->
get
();
$remetentes
=
Notificacao
::
where
(
'remetente_id'
,
Auth
()
->
user
()
->
id
)
->
get
();
$notificacoes
=
$destinatarios
->
merge
(
$remetentes
);
return
view
(
'notificacao.listar'
,[
'notificacoes'
=>
$notificacoes
]);
}
}
app/Notificacao.php
0 → 100644
View file @
545187d1
<?php
namespace
App
;
use
Illuminate\Database\Eloquent\Model
;
class
Notificacao
extends
Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected
$fillable
=
[
'lido'
,
'tipo'
,
'destinatario_id'
,
'remetente_id'
,
'perfil_id'
,
'trabalho_id'
,
];
public
function
destinatario
(){
return
$this
->
belongsTo
(
User
::
class
,
'destinatario_id'
,
'id'
);
}
public
function
remetente
(){
return
$this
->
belongsTo
(
User
::
class
,
'remetente_id'
,
'id'
);
}
public
function
trabalho
(){
return
$this
->
belongsTo
(
Trabalho
::
class
,
'trabalho_id'
,
'id'
);
}
}
database/migrations/2022_01_24_222743_create_notificacaos_table.php
0 → 100644
View file @
545187d1
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateNotificacaosTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'notificacaos'
,
function
(
Blueprint
$table
)
{
$table
->
bigIncrements
(
'id'
);
$table
->
integer
(
'remetente_id'
);
$table
->
integer
(
'destinatario_id'
);
$table
->
integer
(
'trabalho_id'
);
$table
->
integer
(
'perfil_id'
)
->
nullable
();
$table
->
boolean
(
'lido'
);
$table
->
integer
(
'tipo'
);
//1 para pediu acesso, 2 para recebeu acesso, 3 para objetivo, 4 atividade, 5 sugestao
$table
->
foreign
(
'remetente_id'
)
->
references
(
'id'
)
->
on
(
'users'
);
$table
->
foreign
(
'trabalho_id'
)
->
references
(
'id'
)
->
on
(
'trabalhos'
);
$table
->
foreign
(
'destinatario_id'
)
->
references
(
'id'
)
->
on
(
'users'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'notificacaos'
);
}
}
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