Skip to content

Bug: Model Instantiation #2924

Description

@crustamet

I am trying to load model dynamically just like a controller would work.

Up in my controller i have the namespace set

$Model = 'BannersModel';
$this->Model = new $Model();

But this does not work.
If i have this code

$this->Model = new BannersModel();

This works perfectly.

What i am trying to do only works if i have the hole namespace in the instantiation like this

$Model = 'App\\Models\\BannersModel';
$this->Model = new $Model();

Is there a way to load the model from the namespace without typing the namespace fully when i instantiate ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions