diff --git a/app/Http/Controllers/AnexoController.php b/app/Http/Controllers/AnexoController.php index 99bedf57199783f24944b7ce2da75974c8e366a3..afed0d92b0f2769f046695d45cf42637f2983169 100644 --- a/app/Http/Controllers/AnexoController.php +++ b/app/Http/Controllers/AnexoController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Models\Anexo; +use App\Models\UserPad; use App\Models\Util\Menu; use App\Models\Util\YesOrNo; use Illuminate\Http\Request; @@ -10,28 +11,36 @@ use Illuminate\Http\Request; class AnexoController extends Controller { public function edit($user_pad_id) - { + { $model = Anexo::whereUserPadId($user_pad_id)->first(); + $model = $model ?? new Anexo(); + + $userPad = UserPad::whereId($user_pad_id)->first(); $menu = Menu::PADS; $yesOrNo = YesOrNo::listYesOrNo(); $semestres = Anexo::listSemestre(); $categorias = Anexo::listCategoria(); - //usado para testes; - $model = new Anexo(); - return view('pad.anexo.update', [ + 'userPad' => $userPad, 'model' => $model, 'menu' => $menu, 'yesOrNo' => $yesOrNo, 'semestres' => $semestres, 'categorias' => $categorias, + 'user_pad_id' => $user_pad_id ]); } - //implementar Request com FormRequest public function update(Request $request, $user_pad_id) - { - dd($request->all()); + { + $model = Anexo::whereUserPadId($user_pad_id)->first(); + $model = $model ?? new Anexo(); + $model->fill($request->all()); + + $model->save(); + + session()->flash('success', 'Anexo atualizado com sucesso!'); + return redirect()->route('edit_anexo', ['user_pad_id' => $user_pad_id]); } } diff --git a/app/Models/Anexo.php b/app/Models/Anexo.php index aca3ab872ffef6a89ff56f21fe0a886b1c34dbd4..c5eb1c9d19225147fc965761c85b2d5ad47254e2 100644 --- a/app/Models/Anexo.php +++ b/app/Models/Anexo.php @@ -9,8 +9,8 @@ class Anexo extends Model { use SoftDeletes; - public const SEMESTE_1 = 1; - public const SEMESTE_2 = 2; + public const SEMESTRE_1 = 1; + public const SEMESTRE_2 = 2; public const CATEGORIA_ = 1; // public const CATEGORIA_ = 2; @@ -42,13 +42,21 @@ class Anexo extends Model public static function listSemestre($value = null) { $values = [ - self::SEMESTE_1 => '1º SEMESTRE - JANEIRO - JULHO', - self::SEMESTE_2 => '2º SEMESTRE - AGOSTO - DEZEMBRO', + self::SEMESTRE_1 => '1º SEMESTRE', + self::SEMESTRE_2 => '2º SEMESTRE', ]; return $value !== null? $values[$value] : $values; } + public function campus() { + return $this->belongsTo(Campus::class); + } + + public function curso() { + return $this->belongsTo(Curso::class); + } + public static function listCategoria($value = null) { $values = [ diff --git a/database/migrations/2023_06_13_233026_alter_change_categoria_nivel_to_varchar_anexo_table.php b/database/migrations/2023_06_13_233026_alter_change_categoria_nivel_to_varchar_anexo_table.php new file mode 100644 index 0000000000000000000000000000000000000000..82dfe9eb2b7dc54dad0a51c6dc236ec7502fd9b1 --- /dev/null +++ b/database/migrations/2023_06_13_233026_alter_change_categoria_nivel_to_varchar_anexo_table.php @@ -0,0 +1,32 @@ +string('categoria_nivel')->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('anexo_b', function (Blueprint $table) { + $table->tinyInteger('categoria_nivel')->change(); + }); + } +} diff --git a/resources/views/pad/anexo/_form.blade.php b/resources/views/pad/anexo/_form.blade.php index 24b5e2ee079a8cacbcb4f315987ee8be3587da11..c83cb2ff188e14c0abd66e1a66d560e5926d131c 100644 --- a/resources/views/pad/anexo/_form.blade.php +++ b/resources/views/pad/anexo/_form.blade.php @@ -2,6 +2,8 @@ @csrf
+ +
@@ -11,14 +13,22 @@
- +
- +
@@ -26,21 +36,29 @@
- +
- +
- +
@@ -54,21 +72,29 @@
- +
- - + +
- +
@@ -84,7 +110,15 @@
- +
@@ -100,7 +134,15 @@
- +
@@ -145,7 +187,7 @@ $('#document').mask('###.###.###-##') - $('#carga_horaria').mask('000:00'); + $('#carga_horaria').mask('00:00'); //Config : select2 @@ -183,9 +225,4 @@ allowClear: true }) - $('#afastamento_total').on('change', () => - { - - }).change() - \ No newline at end of file diff --git a/resources/views/pad/anexo/update.blade.php b/resources/views/pad/anexo/update.blade.php index a7a49265a05615f46285184d5345efa030b5307a..bc93e65ecd91c490b7f6d4937cd1a4b3eb100d03 100644 --- a/resources/views/pad/anexo/update.blade.php +++ b/resources/views/pad/anexo/update.blade.php @@ -30,7 +30,7 @@
@include('pad.anexo._form', [ - 'route' => route('update_anexo', ['user_pad_id' => 'null']) + 'route' => route('update_anexo', ['user_pad_id' => $user_pad_id]) ])
diff --git a/resources/views/pad/teacher/view.blade.php b/resources/views/pad/teacher/view.blade.php index af465236ec68e83f2c7454e4af19f105590b675b..e0c0ae8e0657a76d5174be45118b48c738cb68f7 100644 --- a/resources/views/pad/teacher/view.blade.php +++ b/resources/views/pad/teacher/view.blade.php @@ -67,13 +67,13 @@
- {{--
+

Anexo B

-
--}} +