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
d5125a5d
Commit
d5125a5d
authored
Jul 10, 2020
by
carlos
Browse files
deletando users
parent
8c85536f
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/AdministradorController.php
View file @
d5125a5d
...
...
@@ -306,23 +306,37 @@ class AdministradorController extends Controller
public
function
destroy
(
$id
)
{
$user
=
User
::
find
(
$id
);
$adminResp
=
AdministradorResponsavel
::
where
(
'user_id'
,
'='
,
$id
)
->
first
();
$avaliador
=
Avaliador
::
where
(
'user_id'
,
'='
,
$id
)
->
first
();
$proponente
=
Proponente
::
where
(
'user_id'
,
'='
,
$id
)
->
first
();
$participante
=
Participante
::
where
(
'user_id'
,
'='
,
$id
)
->
first
();
$adminResp
=
AdministradorResponsavel
::
where
(
'user_id'
,
$id
)
->
first
();
$coordenador
=
CoordenadorComissao
::
where
(
'user_id'
,
$id
)
->
first
();
$avaliador
=
Avaliador
::
where
(
'user_id'
,
$id
)
->
first
();
$proponente
=
Proponente
::
where
(
'user_id'
,
$id
)
->
first
();
$participantes
=
Participante
::
where
(
'user_id'
,
$id
)
->
get
();
if
(
!
(
is_null
(
$adminResp
)))
{
$adminResp
->
delete
();
}
else
if
(
!
(
is_null
(
$avaliador
)))
{
}
if
(
!
(
is_null
(
$coordenador
)))
{
$evento
=
Evento
::
where
(
'coordenadorId'
,
$coordenador
->
id
)
->
get
();
if
(
isset
(
$evento
)
&&
$evento
->
count
()
>
0
)
{
return
redirect
()
->
back
()
->
withErrors
([
'error'
=>
'Esse coordenador está ligado a um edital'
]);
}
else
{
$coordenador
->
delete
();
}
}
if
(
!
(
is_null
(
$avaliador
)))
{
$avaliador
->
delete
();
}
else
if
(
!
(
is_null
(
$proponente
)))
{
}
if
(
!
(
is_null
(
$proponente
)))
{
$proponente
->
delete
();
}
else
if
(
!
(
is_null
(
$participante
)))
{
$participante
->
delete
();
}
if
(
isset
(
$participantes
)
&&
$participantes
->
count
()
>
0
)
{
return
redirect
()
->
back
()
->
withErrors
([
'error'
=>
'Esse participante está ligado a um projeto que só pode ser deletado por seu proponente'
]);
}
$user
->
delete
();
return
redirect
(
route
(
'admin.usuarios'
)
)
->
with
([
'mensagem'
=>
'Usuário deletado com sucesso'
]);
}
...
...
app/User.php
View file @
d5125a5d
...
...
@@ -7,11 +7,12 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
use
Illuminate\Notifications\Notifiable
;
use
Illuminate\Contracts\Auth\CanResetPassword
;
use
App\Notifications\recuperacaoSenha
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
class
User
extends
Authenticatable
implements
MustVerifyEmail
{
use
Notifiable
;
use
SoftDeletes
;
/**
* The attributes that are mass assignable.
*
...
...
database/migrations/2014_10_12_000000_create_users_table.php
View file @
d5125a5d
...
...
@@ -26,6 +26,7 @@ class CreateUsersTable extends Migration
$table
->
rememberToken
();
$table
->
timestamps
();
$table
->
softDeletes
();
$table
->
timestamp
(
'email_verified_at'
)
->
nullable
();
$table
->
integer
(
'enderecoId'
)
->
nullable
();
...
...
database/migrations/2020_02_06_132418_chaves_estrangeiras.php
View file @
d5125a5d
...
...
@@ -61,13 +61,6 @@ class ChavesEstrangeiras extends Migration
//------------------------------------------------------------------------
Schema
::
table
(
'eventos'
,
function
(
Blueprint
$table
)
{
$table
->
foreign
(
'coordenadorId'
)
->
references
(
'id'
)
->
on
(
'users'
);
});
//------------------------------------------------------------------------
Schema
::
table
(
'mensagems'
,
function
(
Blueprint
$table
)
{
$table
->
foreign
(
'comissaoId'
)
->
references
(
'id'
)
->
on
(
'users'
);
});
...
...
database/migrations/2020_07_02_164936_change_foreign_evento_coordenador.php
0 → 100644
View file @
d5125a5d
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
ChangeForeignEventoCoordenador
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'eventos'
,
function
(
Blueprint
$table
)
{
$table
->
foreign
(
'coordenadorId'
)
->
references
(
'id'
)
->
on
(
'coordenador_comissaos'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
//
}
}
resources/views/administrador/usersAdmin.blade.php
View file @
d5125a5d
...
...
@@ -5,6 +5,17 @@
<
div
class
=
"container"
style
=
"margin-top: 100px;"
>
<
div
class
=
"container"
>
@
if
(
$errors
->
any
())
<
div
class
=
"row"
>
<
div
class
=
"col-md-12"
>
<
ul
style
=
"list-style-type: none;"
>
@
foreach
(
$errors
->
all
()
as
$error
)
<
li
class
=
"alert alert-danger"
role
=
"alert"
>
{{
$error
}}
</
li
>
@
endforeach
</
ul
>
</
div
>
</
div
>
@
endif
<
div
class
=
"row"
>
<
div
class
=
"col-sm-10"
>
<
h3
>
Usuários
</
h3
>
...
...
routes/web.php
View file @
d5125a5d
...
...
@@ -40,7 +40,7 @@ Route::post('/perfil-usuario', 'UserController@editarPerfil'
Route
::
group
([
'middleware'
=>
[
'isTemp'
,
'auth'
,
'verified'
]],
function
(){
//######## Rotas Avaliador ####################################
Route
::
prefix
(
'avaliador'
)
->
name
(
'avaliador.'
)
->
group
(
function
(){
Route
::
prefix
(
'avaliador'
)
->
name
(
'avaliador.'
)
->
group
(
function
(){
Route
::
get
(
'/index'
,
'AvaliadorController@index'
)
->
name
(
'index'
)
->
middleware
(
'auth'
);
Route
::
get
(
'/trabalhos'
,
'AvaliadorController@visualizarTrabalhos'
)
->
name
(
'visualizarTrabalho'
)
->
middleware
(
'auth'
);
Route
::
post
(
'/parecer'
,
'AvaliadorController@parecer'
)
->
name
(
'parecer'
)
->
middleware
(
'auth'
);
...
...
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