Commit d5125a5d authored by carlos's avatar carlos
Browse files

deletando users

parent 8c85536f
......@@ -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']);
}
......
......@@ -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.
*
......
......@@ -26,6 +26,7 @@ class CreateUsersTable extends Migration
$table->rememberToken();
$table->timestamps();
$table->softDeletes();
$table->timestamp('email_verified_at')->nullable();
$table->integer('enderecoId')->nullable();
......
......@@ -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');
});
......
<?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()
{
//
}
}
......@@ -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>
......
......@@ -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');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment