Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

UPDATE: Customize Plan & Charge Models and tables name #966

Merged
merged 8 commits into from
Sep 10, 2021

Conversation

ansezz
Copy link
Contributor

@ansezz ansezz commented Sep 5, 2021

Problem:
I can't use the package in an existing project who has the same tables name & Models

Solution:
I have added the ability to customize/extend Charge & Plane Models also the tables name to avoid any conflict if you have an existing database.

New config I have added:

    'models' => [
        /*
        * The fully qualified class name of the Charge model.
        */
        'charge' => Osiset\ShopifyApp\Storage\Models\Charge::class,

        /*
        * The fully qualified class name of the Plan model.
        */
        'plan' => Osiset\ShopifyApp\Storage\Models\Plan::class,
    ],

    'table_names' => [
        /*
        * The table name for the Charge model.
        */
        'charges' => 'charges',

        /*
        * The table name for the Plan model.
        */
        'plans' => 'plans',
    ]

@ansezz ansezz changed the title Customize Plan & Charge Models and tables name UPDATE: Customize Plan & Charge Models and tables name Sep 6, 2021
@gnikyt
Copy link
Owner

gnikyt commented Sep 8, 2021

@ansezz Good idea!

Can you update all config to be Util::getShopifyConfig.

Example: config('shopify-app.models.charge') would be Util::getShopifyConfig('models.charge').

After this, its good to merge :)

@ansezz
Copy link
Contributor Author

ansezz commented Sep 9, 2021

@osiset Thank you,
I did update all of them, you can check now.

@gnikyt gnikyt added the feature Enhancement to the code label Sep 9, 2021
@gnikyt gnikyt self-assigned this Sep 9, 2021
@gnikyt
Copy link
Owner

gnikyt commented Sep 9, 2021

@ansezz Thanks! Appears to be a syntax error, I suspect you can't init a class that way... ie new (Util::getShopifyConfig('models.something', Something::class)), it may need to be:

$kclass = Util::getShopifyConfig('models.something', Something::class);
... new $klass;

@ansezz
Copy link
Contributor Author

ansezz commented Sep 9, 2021

@osiset Yeah!
It was in PHP 7, I did fix it now
Thanks

@gnikyt
Copy link
Owner

gnikyt commented Sep 10, 2021

Passing, thanks for the feature, I'll merge!

@gnikyt gnikyt merged commit d8c61ae into gnikyt:master Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Enhancement to the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants