public static function withBillets(Resource $resource)
    {
        $controller = new static;

        $list = $resource->getList();
        if (empty($list)) {
            return false;
        }

        foreach ($list as $id) {
            if (!$controller->generate($id)) {
                return false;
            }

            $title_list = BankInterchange\Models\Title::dump(
                ['shipping_file' => $id['id']],
                BankInterchange\Models\Title::PRIMARY_KEY
            );

            $bankbillet = new BankInterchange\BankBillet\Controller;
            foreach ($title_list as $title_id) {
                if (!$bankbillet->generate($title_id)) {
                    return false;
                }
            }
            $billets = $bankbillet->dump() ?? [];

            if ($resource->kind === 'collection') {
                $model = (static::MODEL_CLASS)::getInstance($id);
                $directory = "{$model->assignment->id}-$model->counter/";

                $current = count($controller->views) - 1;
                $filename = $controller->views[$current]['name'];
                $controller->views[$current]['name'] = $directory . $filename;

                foreach ($billets as $billet_id => $billet) {
                    $billets[$billet_id]['name'] = $directory . $billet['name'];
                }
            }

            $controller->views = array_merge($controller->views, $billets);
        }

        $controller->zip();

        return true;
    }
public static function withBillets(Resource $resource)
    {
        $controller = new static;

        $list = $resource->getList();
        if (empty($list)) {
            return false;
        }

        foreach ($list as $id) {
            if (!$controller->generate($id)) {
                return false;
            }

            $title_list = BankInterchange\Models\Title::dump(
                ['shipping_file' => $id['id']],
                BankInterchange\Models\Title::PRIMARY_KEY
            );

            $bankbillet = new BankInterchange\BankBillet\Controller;
            foreach ($title_list as $title_id) {
                if (!$bankbillet->generate($title_id)) {
                    return false;
                }
            }
            $billets = $bankbillet->dump() ?? [];

            if ($resource->kind === 'collection') {
                $model = (static::MODEL_CLASS)::getInstance($id);
                $directory = "{$model->assignment->id}-$model->counter/";

                $current = count($controller->views) - 1;
                $filename = $controller->views[$current]['name'];
                $controller->views[$current]['name'] = $directory . $filename;

                foreach ($billets as $billet_id => $billet) {
                    $billets[$billet_id]['name'] = $directory . $billet['name'];
                }
            }

            $controller->views = array_merge($controller->views, $billets);
        }

        $controller->zip();

        return true;
    }
public static function withBillets ( Resource $ resource ) { $ controller = new static ; $ list = $ resource -> getList ( ) ; if ( empty ( $ list ) ) { return false ; } foreach ( $ list as $ id ) { if ( ! $ controller -> generate ( $ id ) ) { return false ; } $ title_list = BankInterchange \ Models \ Title :: dump ( [ 'shipping_file' => $ id [ 'id' ] ] , BankInterchange \ Models \ Title :: PRIMARY_KEY ) ; $ bankbillet = new BankInterchange \ BankBillet \ Controller ; foreach ( $ title_list as $ title_id ) { if ( ! $ bankbillet -> generate ( $ title_id ) ) { return false ; } } $ billets = $ bankbillet -> dump ( ) ?? [ ] ; if ( $ resource -> kind === 'collection' ) { $ model = ( static :: MODEL_CLASS ) :: getInstance ( $ id ) ; $ directory = "{$model->assignment->id}-$model->counter/" ; $ current = count ( $ controller -> views ) - 1 ; $ filename = $ controller -> views [ $ current ] [ 'name' ] ; $ controller -> views [ $ current ] [ 'name' ] = $ directory . $ filename ; foreach ( $ billets as $ billet_id => $ billet ) { $ billets [ $ billet_id ] [ 'name' ] = $ directory . $ billet [ 'name' ] ; } } $ controller -> views = array_merge ( $ controller -> views , $ billets ) ; } $ controller -> zip ( ) ; return true ; }
Creates a zip file with shipping files and their billets

If $resource is a collection, the generated files are organized in
directories for each shipping file.

@param Resource $resource Processed MedoolsRouter Resource

@return boolean For success or failure
Creates a zip file with shipping files and their billets