How to extract the same code part of the laravel controller into a common part

now there are user An and user B platforms, both of which have a page with income and expenditure records. So the contents of the two controllers are basically the same, but there are still some differences, such as

 return view"";

because there are also small differences in the middle. So I don"t know what good way to extract it.

The

view section has the @ yield,@section way. Whether the controller has a similar way.

Jul.10,2022

No, package the method yourself

Menu