Skip to content

Commit

Permalink
Merge pull request #864 from portabilis/portabilis-patch-2022-07-10
Browse files Browse the repository at this point in the history
[2.7] Portabilis patch 10/07/2022
  • Loading branch information
edersoares authored Jul 10, 2022
2 parents 24321bf + 9560798 commit c8310ae
Show file tree
Hide file tree
Showing 24 changed files with 505 additions and 162 deletions.
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Kernel extends HttpKernel
],

'api' => [
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'bindings',
'throttle:60,1',
],
Expand Down
14 changes: 14 additions & 0 deletions app/Http/Middleware/SkipMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class SkipMiddleware
{
public function handle(Request $request, Closure $next): mixed
{
return $next($request);
}
}
31 changes: 31 additions & 0 deletions app/Models/LegacyMenuUserType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace App\Models;

use App\Menu;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class LegacyMenuUserType extends Model
{
use HasFactory;

protected $table = 'pmieducar.menu_tipo_usuario';

public $timestamps = false;
public $primaryKey = null;
public $incrementing = false;

protected $fillable = [
'ref_cod_tipo_usuario',
'menu_id',
'cadastra',
'visualiza',
'exclui',
];

public function menus()
{
return $this->belongsTo(Menu::class);
}
}
4 changes: 2 additions & 2 deletions app/Models/LegacyUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App\User as DefaultUser;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class LegacyUser extends Model
class LegacyUser extends DefaultUser
{
/**
* @var string
Expand Down
2 changes: 1 addition & 1 deletion app/Repositories/EducacensoRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ public function getEmployeeDataForRecord30($arrayEmployeeId)
SELECT ARRAY_REMOVE(ARRAY_AGG(educacenso_curso_superior.curso_id), NULL) course_id,
ARRAY_REMOVE(ARRAY_AGG(completion_year), NULL) completion_year,
ARRAY_REMOVE(ARRAY_AGG(educacenso_ies.ies_id), NULL) college_id,
ARRAY_REMOVE(ARRAY_AGG(discipline_id), NULL) discipline_id
ARRAY_REMOVE(ARRAY_AGG(coalesce(discipline_id, 0)), NULL) discipline_id
FROM employee_graduations
JOIN modules.educacenso_curso_superior ON educacenso_curso_superior.id = employee_graduations.course_id
JOIN modules.educacenso_ies ON educacenso_ies.id = employee_graduations.college_id
Expand Down
2 changes: 2 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Carbon;
use Laravel\Sanctum\HasApiTokens;

/**
* @property int $id
Expand All @@ -26,6 +27,7 @@
*/
class User extends Authenticatable
{
use HasApiTokens;
use Notifiable;

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Software livre de gestão escolar",
"type": "project",
"license": "GPL-2.0-or-later",
"version": "2.7.2",
"version": "2.7.3",
"keywords": [
"Portabilis",
"i-Educar"
Expand Down
55 changes: 28 additions & 27 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions config/sanctum.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
*/

'middleware' => [
'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
'verify_csrf_token' => App\Http\Middleware\SkipMiddleware::class,
'encrypt_cookies' => App\Http\Middleware\SkipMiddleware::class,
],

];
81 changes: 81 additions & 0 deletions database/factories/LegacyMenuUserTypeFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

namespace Database\Factories;

use App\Models\LegacyMenuUserType;
use App_Model_NivelTipoUsuario;
use Illuminate\Database\Eloquent\Factories\Factory;

class LegacyMenuUserTypeFactory extends Factory
{
protected $model = LegacyMenuUserType::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition()
{
return [
'ref_cod_tipo_usuario' => LegacyUserTypeFactory::new()->create(
[
'nivel' => $this->faker->randomElement([
App_Model_NivelTipoUsuario::POLI_INSTITUCIONAL,
App_Model_NivelTipoUsuario::INSTITUCIONAL,
App_Model_NivelTipoUsuario::ESCOLA,
App_Model_NivelTipoUsuario::BIBLIOTECA
]),
]
),
'menu_id' => MenuFactory::new()->create()->getKey(),
'cadastra' => 1,
'visualiza' => 1,
'exclui' => 1,
];
}

public function admin()
{
return $this->state(
[
'ref_cod_tipo_usuario' => LegacyUserTypeFactory::new()->create(
['nivel' => App_Model_NivelTipoUsuario::POLI_INSTITUCIONAL]
)
]
);
}

public function institutional()
{
return $this->state(
[
'ref_cod_tipo_usuario' => LegacyUserTypeFactory::new()->create(
['nivel' => App_Model_NivelTipoUsuario::INSTITUCIONAL]
)
]
);
}

public function school()
{
return $this->state(
[
'ref_cod_tipo_usuario' => LegacyUserTypeFactory::new()->create(
['nivel' => App_Model_NivelTipoUsuario::ESCOLA]
)
]
);
}

public function library()
{
return $this->state(
[
'ref_cod_tipo_usuario' => LegacyUserTypeFactory::new()->create(
['nivel' => App_Model_NivelTipoUsuario::ESCOLA]
)
]
);
}
}
27 changes: 27 additions & 0 deletions database/factories/LegacyUserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ public function definition(): array
];
}

public function admin(): static
{
return $this->state([
'ref_cod_tipo_usuario' => function () {
return LegacyUserTypeFactory::new()->create([
'nivel' => 1,
]);
},
]);
}

public function unique()
{
return $this->state(function () {
Expand All @@ -53,4 +64,20 @@ public function unique()
];
});
}

public function withAccess($process, $view = true, $modify = true, $remove = true): static
{
return $this->afterCreating(function (LegacyUser $user) use ($process, $view, $modify, $remove) {
$menu = MenuFactory::new()->create(
['process' => $process]
);
LegacyMenuUserTypeFactory::new()->create([
'menu_id' => $menu,
'ref_cod_tipo_usuario' => $user->type,
'cadastra' => $modify,
'visualiza' => $view,
'exclui' => $remove,
]);
});
}
}
Loading

0 comments on commit c8310ae

Please sign in to comment.