How to correctly use laravel package development and dependency decoupling problem

Question1: now I want to develop a system for customers, some functions are free, some functions are charged, do you want to turn each major function into a laravel package, and decide what to quote according to the customer"s difference?
is such a requirement in line with the original intention of package development?

question 2: how to solve model dependencies or other dependencies when developing in this way. For example, I will write user module as a package and article module as a package. Both packages use userModel. What should I do with the dependencies here?
if I define the model, in two packages, the code is repeated, which doesn"t seem to be a good experience.
it"s not good to say that I rely on user module in article module, because I want packages to be independent of each other.
was very tangled and didn"t come up with a solution.

the core question is: I want to build a system, I want each module (package) to be independent of each other, what function I want to add, or what function I want to reduce, I just need to deal with the module (package).

Mar.20,2021

your requirement can be solved through routing and middleware. For example, users need to charge to access / order/add , but access to order/list is free, then you can configure it as follows:

Route::group('middleware' => ['auth.needPay']], function () {
    Route::get('order/add', ['uses' => 'Order@add']);
});
Route::group('middleware' => ['auth.free']], function () {
    Route::get('order/list', ['uses' => 'Order@list']);
});
For

how to add middleware, please refer to document

.
Menu