<?php

namespace Orchestra\Foundation\Jobs;

use Orchestra\Contracts\Authorization\Authorization;
use Orchestra\Model\Role;

class SyncDefaultAuthorization extends Job
{
    /**
     * Re-sync administrator access control.
     *
     * @param  \Orchestra\Contracts\Authorization\Authorization  $acl
     *
     * @return void
     */
    public function handle(Authorization $acl)
    {
        $actions = \config('orchestra/foundation::actions', []);
        $attaches = [];

        foreach ($actions as $action) {
            if (! $acl->actions()->has($action)) {
                $attaches[] = $action;
            }
        }

        if (! empty($attaches)) {
            $acl->actions()->attach($attaches);
        }

        $admin = Role::hs()->admin();

        $acl->allow($admin->name, $actions);
    }
}

<?php

namespace Orchestra\Foundation\Jobs;

use Orchestra\Contracts\Authorization\Authorization;
use Orchestra\Model\Role;

class SyncDefaultAuthorization extends Job
{
    /**
     * Re-sync administrator access control.
     *
     * @param  \Orchestra\Contracts\Authorization\Authorization  $acl
     *
     * @return void
     */
    public function handle(Authorization $acl)
    {
        $actions = \config('orchestra/foundation::actions', [
            'Manage Users', 'Manage Orchestra', 'Manage Roles', 'Manage Acl',
        ]);

        $attaches = [];

        foreach ($actions as $action) {
            if (! $acl->actions()->has($action)) {
                $attaches[] = $action;
            }
        }

        if (! empty($attaches)) {
            $acl->actions()->attach($attaches);
        }

        $admin = Role::hs()->admin();

        $acl->allow($admin->name, $actions);
    }
}

Add default value in case missing.
Add default value in case missing.

Signed-off-by: Mior Muhammad Zaki <e1a543840a942eb68427510a8a483282a7bfeddf@gmail.com>
