rinvex / cortex-foundation-classic

The core foundation of Rinvex Cortex modular application architecture.
MIT License
7 stars 5 forks source link

use morph map with abilities check #343

Closed mohamed-hendawy closed 1 year ago

Omranic commented 1 year ago

Please note that the 2nd parameter which you're modifying here as $morphMap[$this->resource] in $this->authorizeResource($this->resource, $morphMap[$this->resource] ?? null); refers to a route parameter, not model name when it's resolved by the authorization logic, so they're not related in any way.

By default, the naming convention is that the model class name should match it's own route parameter, whether you're doing implicit or explicit model binding. (REF)

mohamed-hendawy commented 1 year ago

if we have two models with the same name Application in two modules for example application in courses and jobs modules so route parameter will be different one is course_application and the other is job_application, how will it work in this case?

Omranic commented 1 year ago

It doesn’t matter, because as I mentioned this parameter is resolved from route parameters of the current request.

It doesn’t know or be aware of any other modules or models, it has access to the current request objects, and expects that parameter to be given in it with the same name, so you can have million similar route parameters as long as it’s not in the same route. There’s no uniqueness needed cross modules.

Let me know if this is still not clear.