z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.15k stars 2.82k forks source link

[Question] How to extends form between classes #5582

Closed hoangnamitc closed 2 years ago

hoangnamitc commented 2 years ago

Hello,

I have a class with a form method and I want to inherit that method for other classes, how do I do that?

class A
{
   /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new ClassA());

        $form->text('title', 'Title');

        return $form;
    }
}

class B
{
    protected function form()
    {
        $form = new Form(new ClassB());
        // How to extends method form() of class A to here ??

        $form->textarea('desc', 'Description');
        return $form;
    }
}

Thanks!