Skip to content

Commit

Permalink
Merge pull request #1021 from uasoft-indonesia/analysis-djmZj9
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
rahmatalmubarak authored Aug 10, 2023
2 parents 2a37cfc + a372595 commit 7090894
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Models/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(array $attributes = [])

public static function generateFor($table_name, $is_maintenance = false)
{
if(!Permission::where('table_name', $table_name)->first()){
if (! Permission::where('table_name', $table_name)->first()) {
$permissions = [];
$permissions[] = self::firstOrCreate(['key' => 'browse_'.$table_name, 'description' => 'Browse '.$table_name, 'table_name' => $table_name, 'roles_can_see_all_data' => '["administrator"]', 'field_identify_related_user' => 'user_id']);
$permissions[] = self::firstOrCreate(['key' => 'read_'.$table_name, 'description' => 'Read '.$table_name, 'table_name' => $table_name, 'roles_can_see_all_data' => '["administrator"]', 'field_identify_related_user' => 'user_id']);
Expand Down Expand Up @@ -97,13 +97,14 @@ public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()->dontSubmitEmptyLogs();
}

public static function generateForTableCRUD(){

public static function generateForTableCRUD()
{
$get_all_table_name = DataType::all();
foreach ($get_all_table_name as $key => $table) {
$permission_table_name = Permission::where('table_name', $table->name)->get();
foreach ($permission_table_name as $key => $table_name) {
if ($table->roles_can_see_all_data == NULL && $table_name->field_identify_related_user == NULL) {
if ($table->roles_can_see_all_data == null && $table_name->field_identify_related_user == null) {
$table_name->roles_can_see_all_data = '["administrator"]';
$table_name->field_identify_related_user = 'user_id';
$table_name->save();
Expand Down

0 comments on commit 7090894

Please sign in to comment.