Support the ongoing development of Laravel.io →
Eloquent Packages Architecture
Last updated 2 years ago.
0

A code snippet is on the PHP manual page for extends that should be of interest to you:

http://php.net/manual/en/keyword.extends.php#98665

0

PHP does not allow for multiple intheritance. You could take a look at decorator pattern which is kind of multiple inheritance, but I don't think that the stuff you want to do will be that easy to do. Maybe something like this:

class Extended extends APlainPHPModelFromLibrary{
    protected $model;
    public function __construct(Model $model){ //Illuminate\Database\Eloquent\Model
        $this->model = $model;
    }
    public function __call($name, $arguments){
        call_user_func_array([$this->model, $name], $arguments);
    }
}

This way you would most likely be allowed to use method from Eloquent if it does not appear in your APlainPHPModelFromLibrary. You could do same for getters and setters. It is kind of tricky and I don't say it is most optimal solution since I don't know what exacly you need. Maybe someone will give you some better clue.

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.