src/Database/Migration.php
public static function addPermissions(array $permissions)
    {
        $rows = [];

        foreach ($permissions as $permission => $groups) {
            foreach ((array) $groups as $group) {
                $rows[] = [
                    'group_id' => $group,
                    'permission' => $permission,
                ];
            }
        }

        return [
            'up' => function (Builder $schema) use ($rows) {
                $db = $schema->getConnection();

                foreach ($rows as $row) {
                    if ($db->table('group_permission')->where($row)->exists()) {
                        continue;
                    }

                    if ($db->table('groups')->where('id', $row['group_id'])->doesntExist()) {
                        continue;
                    }

                    $db->table('group_permission')->insert($row);
                }
            },

            'down' => function (Builder $schema) use ($rows) {
                $db = $schema->getConnection();

                foreach ($rows as $row) {
                    $db->table('group_permission')->where($row)->delete();
                }
            }
        ];
    }
public static function addPermissions(array $permissions)
    {
        $rows = [];

        foreach ($permissions as $permission => $groups) {
            foreach ((array) $groups as $group) {
                $rows[] = [
                    'group_id' => $group,
                    'permission' => $permission,
                ];
            }
        }

        return [
            'up' => function (Builder $schema) use ($rows) {
                $db = $schema->getConnection();

                foreach ($rows as $row) {
                    if ($db->table('group_permission')->where($row)->exists()) {
                        continue;
                    }

                    if ($db->table('groups')->where('id', $row['group_id'])->doesntExist()) {
                        continue;
                    }

                    $db->table('group_permission')->insert($row);
                }
            },

            'down' => function (Builder $schema) use ($rows) {
                $db = $schema->getConnection();

                foreach ($rows as $row) {
                    $db->table('group_permission')->where($row)->delete();
                }
            }
        ];
    }
public static function addPermissions ( array $ permissions ) { $ rows = [ ] ; foreach ( $ permissions as $ permission => $ groups ) { foreach ( ( array ) $ groups as $ group ) { $ rows [ ] = [ 'group_id' => $ group , 'permission' => $ permission , ] ; } } return [ 'up' => function ( Builder $ schema ) use ( $ rows ) { $ db = $ schema -> getConnection ( ) ; foreach ( $ rows as $ row ) { if ( $ db -> table ( 'group_permission' ) -> where ( $ row ) -> exists ( ) ) { continue ; } if ( $ db -> table ( 'groups' ) -> where ( 'id' , $ row [ 'group_id' ] ) -> doesntExist ( ) ) { continue ; } $ db -> table ( 'group_permission' ) -> insert ( $ row ) ; } } , 'down' => function ( Builder $ schema ) use ( $ rows ) { $ db = $ schema -> getConnection ( ) ; foreach ( $ rows as $ row ) { $ db -> table ( 'group_permission' ) -> where ( $ row ) -> delete ( ) ; } } ] ; }
Add default permissions.
Add default permissions .