Commit d913684e authored by alissonalbuquerque's avatar alissonalbuquerque
Browse files

add correções de buttons

parent 4ab799ca
......@@ -9,6 +9,7 @@ use App\Models\Tabelas\Constants;
use App\Models\User;
use App\Models\UserPad;
use App\Models\UserType;
use App\Models\UserTypePad;
use App\Models\Util\Menu;
use App\Models\Util\MenuItemsAdmin;
use App\Models\Util\MenuItemsTeacher;
......@@ -29,7 +30,9 @@ class PadController extends Controller
*/
public function index()
{
if(Auth::user()->isTypeAdmin()) {
if(Auth::user()->isTypeAdmin())
{
$users = User::initQuery()->whereType(UserType::TEACHER)->get();
$pads = Pad::all();
$menu = Menu::PADS;
return view('pad.admin.index', ['menu' => $menu, 'pads' => $pads]);
......@@ -48,7 +51,8 @@ class PadController extends Controller
* @param integer $id
* @return \Illuminate\Http\Response
*/
public function view($id) {
public function view($id)
{
$menu = Menu::PADS;
return view('pad.teacher.view', ['user_pad_id' => $id, 'menu' => $menu]);
}
......@@ -86,18 +90,24 @@ class PadController extends Controller
'data_fim.after_or_equal' => 'A :attribute deve ser uma data posterior ou igual a data de início',
]);
if($validated) {
if($validated)
{
$model = new Pad($request->all());
if($model->save()) {
if($model->save())
{
$users = User::initQuery()->whereType(UserType::TEACHER)->get();
foreach($users as $user) {
$modelUserPad = new UserPad();
$modelUserPad->user_id = $user->id;
$modelUserPad->pad_id = $model->id;
$modelUserPad->save();
foreach($users as $user)
{
$profile = $user->profile(UserType::TEACHER);
$userPad = new UserPad();
$userPad->pad_id = $model->id;
$userPad->user_type_id = $profile->id;
$userPad->status = Status::ATIVO;
$userPad->save();
}
return redirect()->route('pad_index')->with('success', 'PAD cadastrado com sucesso!');
......@@ -113,44 +123,6 @@ class PadController extends Controller
return view('pad.anexo', ['index_menu' => 1 ]);
}
// /**
// * Store a newly created resource in storage.
// *
// * @param \Illuminate\Http\Request $request
// * @return \Illuminate\Http\Response
// */
// public function store(Request $request)
// {
// $rules = [
// 'first_name' => 'required|string|min:3|max:255',
// 'city_name' => 'required|string|min:3|max:255',
// 'email' => 'required|string|email|max:255'
// ];
// $validator = Validator::make($request->all(),$rules);
// if ($validator->fails()) {
// return redirect('insert')
// ->withInput()
// ->withErrors($validator);
// }
// else{
// $data = $request->input();
// try{
// $student = new StudInsert;
// $student->first_name = $data['first_name'];
// $student->last_name = $data['last_name'];
// $student->city_name = $data['city_name'];
// $student->email = $data['email'];
// $student->save();
// return redirect('insert')->with('status',"Insert successfully");
// }
// catch(Exception $e){
// return redirect('insert')->with('failed',"operation failed");
// }
// }
// return redirect('/dashboard');
// }
/**
* Show the form for editing the specified resource.
*
......
......@@ -83,7 +83,8 @@ class UserController extends Controller
$password = array_shift($email_splited);
$model->password = Hash::make($password);
if($model->save()) {
if($model->save())
{
return redirect()->route('user_edit', ['id' => $model->id])->with('success', 'Usuário cadastrado com sucesso!');
}
......
......@@ -23,7 +23,7 @@ class EnsinoAula extends Model
*
* @var array
*/
protected $fillable = ['orientacao_id', 'user_pad_id', 'dimensao', 'cod_atividade', 'componente_curricular', 'curso', 'nivel', 'modalidade', 'ch_semanal', 'ch_total'];
protected $fillable = ['orientacao_id', 'user_pad_id', 'cod_dimensao', 'dimensao', 'cod_atividade', 'componente_curricular', 'curso', 'nivel', 'modalidade', 'ch_semanal', 'ch_total'];
public static function rules()
{
......
......@@ -131,8 +131,16 @@ class User extends Authenticatable
return $this->belongsTo(Unidade::class);
}
public function profile($type_profile)
{
return UserType::initQuery()
->whereUser($this->id)
->whereType($type_profile)
->first();
}
public function perfis()
/** @return UserType[]|null */
public function profiles()
{
return $this->hasMany(UserType::class);
}
......@@ -140,9 +148,9 @@ class User extends Authenticatable
/**
* @return UserType|Null
*/
public function perfilSelected()
public function profileSelected()
{
return $this->perfis()->where('selected', true)->first();
return $this->profiles()->where('selected', true)->first();
}
/**
......@@ -150,7 +158,7 @@ class User extends Authenticatable
*/
public function isTypeAdmin()
{
return $this->perfilSelected()->type === UserType::ADMIN;
return $this->profileSelected()->type === UserType::ADMIN;
}
/**
......@@ -158,7 +166,7 @@ class User extends Authenticatable
*/
public function isTypeTeacher()
{
return $this->perfilSelected()->type === UserType::TEACHER;
return $this->profileSelected()->type === UserType::TEACHER;
}
/**
......@@ -166,7 +174,7 @@ class User extends Authenticatable
*/
public function isTypeDirector()
{
return $this->perfilSelected()->type === UserType::DIRECTOR;
return $this->profileSelected()->type === UserType::DIRECTOR;
}
/**
......@@ -174,7 +182,7 @@ class User extends Authenticatable
*/
public function isTypeCoordinator()
{
return $this->perfilSelected()->type === UserType::COORDINATOR;
return $this->profileSelected()->type === UserType::COORDINATOR;
}
/**
......@@ -182,7 +190,7 @@ class User extends Authenticatable
*/
public function isTypeEvaluator()
{
return $this->perfilSelected()->type === UserType::EVALUATOR;
return $this->profileSelected()->type === UserType::EVALUATOR;
}
public static function initQuery()
......
......@@ -3,23 +3,31 @@
namespace App\Models;
use App\Queries\UserPadQuery;
use App\Models\Pad;
use App\Models\Util\Status;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
//remover tabela de user_pad
class UserPad extends Model
{
use HasFactory;
protected $table = 'user_pad';
protected $fillable = ['user_id', 'pad_id'];
protected $fillable = ['user_type_id', 'pad_id', 'status'];
public function user() {
return $this->belongsTo(User::class);
return $this->belongsTo(UserType::class);
}
public function pad() {
return $this->belongsTo(PAD::class);
return $this->belongsTo(Pad::class);
}
public function statusAsText() {
return Status::listStatus($this->status);
}
public static function initQuery() {
......
......@@ -39,7 +39,7 @@ class UserType extends Model
return Status::listStatus($this->status);
}
public function initQuery()
public static function initQuery()
{
return new UserTypeQuery(get_called_class());
}
......
......@@ -9,6 +9,7 @@ class Status
const INATIVO = 2;
const PENDENTE = 3;
const ARQUIVADO = 4;
const FINALIZADO = 5;
public static function listStatus($value = null) {
......@@ -17,6 +18,7 @@ class Status
self::INATIVO => 'Inativo',
self::PENDENTE => 'Pendente',
self::ARQUIVADO => 'Arquivado',
self::FINALIZADO => 'Finalizado',
];
return $value !== null? $values[$value] : $values;
......
......@@ -24,12 +24,12 @@ class UserPadQuery extends CustomQuery
}
/**
* @param integer $user_id
* @param integer $user_type_id
* @return UserPadQuery|Builder
*/
public function whereUser($user_id, $operator = '=')
public function whereUser($user_type_id, $operator = '=')
{
$this->query = $this->query->where('user_id', $operator, $user_id);
$this->query = $this->query->where('user_type_id', $operator, $user_type_id);
return self::$instance;
}
......@@ -43,6 +43,16 @@ class UserPadQuery extends CustomQuery
return self::$instance;
}
/**
* @param integer $status
* @return UserPadQuery|Builder
*/
public function whereStatus($status, $operator = '=')
{
$this->query = $this->query->where('status', $operator, $status);
return self::$instance;
}
/**
* @param integer $status
* @return UserPadQuery|Builder
......
......@@ -14,4 +14,24 @@ class UserTypeQuery extends CustomQuery
self::$instance = $this;
}
public function whereType($type, $expression = "=")
{
$this->query = $this->query->where('type', $expression, $type);
return self::$instance;
}
public function whereUser($user_id, $expression = "=")
{
$this->query = $this->query->where('user_id', $expression, $user_id);
return self::$instance;
}
public function whereStatus($status, $expression = "=")
{
$this->query = $this->query->where('status', $expression, $status);
return self::$instance;
}
}
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePADSTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('pads', function (Blueprint $table) {
$table->id();
$table->integer('ano')->default(false);
$table->integer('semestre')->default(false);
$table->integer('carga_horaria')->default(false);
$table->string('categoria', 20)->default(false);
$table->boolean('afastamento_total')->default(false);
$table->boolean('afastamento_parcial')->default(false);
$table->boolean('exerce_funcao_admin')->default(false);
$table->boolean('exerce_funcao_sindical')->default(false);
$table->string('licenca_de_acor_legais', 50)->default(null);
$table->string('outras_observacoes', 200)->nullable(true);
$table->foreignId('user_id');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('pads');
}
}
......@@ -13,10 +13,12 @@ class CreateUserPadTable extends Migration
*/
public function up()
{
Schema::create('user_pad', function (Blueprint $table) {
Schema::create('user_pad', function (Blueprint $table)
{
$table->id();
$table->foreignId('user_id');
$table->foreignId('user_type_id');
$table->foreignId('pad_id');
$table->tinyInteger('status');
$table->timestamps();
});
}
......
......@@ -16,7 +16,6 @@ class CreateUserTypeTable extends Migration
Schema::create('user_type', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id');
$table->foreignId('pad_id')->nullable();
$table->tinyInteger('type');
$table->tinyInteger('status');
$table->boolean('selected');
......
......@@ -6,7 +6,7 @@
--}}
<div class="btn-edit-tasks">
<button type="button" class="btn btn-primary {{ $btn_class }}" id="{{ $btn_id }}">
<button type="button" class="btn btn-primary btn-sm {{ $btn_class }}" id="{{ $btn_id }}">
<i class="bi bi-pencil-square"></i>
</button>
</div>
\ No newline at end of file
......@@ -121,15 +121,20 @@
<td>{{ $atividade->nivelAsString() }}</td>
<td>{{ $atividade->ch_semanal }}</td>
<td>
<div class="btn-group" role="group">
<div class="me-1">
@include('components.buttons.btn-edit-task', [
'btn_class' => 'btn-edit_ensino_atendimento_discente',
'btn_id' => $atividade->id,
])
</div>
<div class="me-1">
@include('components.buttons.btn-delete', [
'id' => $atividade->id,
'route' => route('ensino_atendimento_discente_delete', ['id' => $atividade->id])
])
</div>
</div>
</td>
</tr>
@endforeach
......
......@@ -160,15 +160,20 @@
<td>{{ $ensinoAula->modalidadeAsString() }}</td>
<td>{{ $ensinoAula->ch_semanal }}</td>
<td>
<div class="btn-group" role="group">
<div class="me-1">
@include('components.buttons.btn-edit-task', [
'btn_class' => 'btn-edit_ensino_aula',
'btn_id' => $ensinoAula->id,
])
</div>
<div class="me-1">
@include('components.buttons.btn-delete', [
'id' => $ensinoAula->id,
'route' => route('ensino_aula_delete', ['id' => $ensinoAula->id])
])
</div>
</div>
</td>
</tr>
@endforeach
......
......@@ -122,15 +122,20 @@
<td>{{ $atividade->funcaoAsString() }}</td>
<td>{{ $atividade->ch_semanal }}</td>
<td>
<div class="btn-group" role="group">
<div class="me-1">
@include('components.buttons.btn-edit-task', [
'btn_class' => 'btn-edit_ensino_membro_docente',
'btn_id' => $atividade->id,
])
</div>
<div class="me-1">
@include('components.buttons.btn-delete', [
'id' => $atividade->id,
'route' => route('ensino_membro_docente_delete', ['id' => $atividade->id])
])
</div>
</div>
</td>
</tr>
@endforeach
......
......@@ -171,15 +171,20 @@
<td>{{ $ensinoOrientacao->orientacaoAsString() }}</td>
<td>{{ $ensinoOrientacao->chSemanal() }}</td>
<td>
<div class="btn-group" role="group">
<div class="me-1">
@include('components.buttons.btn-edit-task', [
'btn_class' => 'btn-edit_ensino_orientacao',
'btn_id' => $ensinoOrientacao->id,
])
</div>
<div class="me-1">
@include('components.buttons.btn-delete', [
'id' => $ensinoOrientacao->id,
'route' => route('ensino_orientacao_delete', ['id' => $ensinoOrientacao->id])
])
</div>
</div>
</td>
</tr>
@endforeach
......
......@@ -105,15 +105,20 @@
<td>{{ $atividade->descricao }}</td>
<td>{{ $atividade->ch_semanal }}</td>
<td>
<div class="btn-group" role="group">
<div class="me-1">
@include('components.buttons.btn-edit-task', [
'btn_class' => 'btn-edit_ensino_outros',
'btn_id' => $atividade->id,
])
</div>
<div class="me-1">
@include('components.buttons.btn-delete', [
'id' => $atividade->id,
'route' => route('ensino_outros_delete', ['id' => $atividade->id])
])
</div>
</div>
</td>
</tr>
@endforeach
......
......@@ -111,15 +111,20 @@
<td>{{ $atividade->nivelAsString() }}</td>
<td>{{ $atividade->ch_semanal }}</td>
<td>
<div class="btn-group" role="group">
<div class="me-1">
@include('components.buttons.btn-edit-task', [
'btn_class' => 'btn-edit_ensino_participacao',
'btn_id' => $atividade->id,
])
</div>
<div class="me-1">
@include('components.buttons.btn-delete', [
'id' => $atividade->id,
'route' => route('ensino_participacao_delete', ['id' => $atividade->id])
])
</div>
</div>
</td>
</tr>
@endforeach
......
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