N
N
Nikita Petiev2021-02-11 01:16:26
Laravel
Nikita Petiev, 2021-02-11 01:16:26

How to properly organize the revision of the tcg/voyager admin package?

I want to say right away that there will be a lot of text, I’m still studying laravel, and I don’t know many subtleties, so I can be wrong in my reasoning. I ask this question more to people who have been working with laravel for a long time and have a lot of experience with it.

The tcg/voyager admin package is implemented on some basic models of the laravel framework, so I needed to refine some basic models - let's take the users model for example. I added SoftDeletes to it, and inherited it from the users model, directly from the voyager package, set up the configs, everything worked with my refinement, but the basic UserDimmer widget stopped working because it works on the voyager user model. After a little digging into the source code and documentation of the package, I figured it out and decided to make my own widget based on my modernized users model, made a new widget and everything works. But there is one catch - I'm not sure that this method is correct in terms of organizing the structure of files, their purpose and solving the problem by the laravel way. Please share advice and examples, how would you solve this, in general,

Below in the screenshots, an example of my implementation of the file structure and the code itself - I had to make a CustomVoyager descendant (I could not determine what it is according to the laravel architecture, and in which folder to define it) from the original Voyager application class, which, when initialized, changes its property - an array of base models of the application models, and calls it Facade to determine whether this widget can be shown to the user or if he does not have rights to do so, in my case the CustomVoyager is initialized in my CustomUserDimmer widget.

60245b0122ff6693478804.jpeg
60245b1116ede583829021.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita Petiev, 2021-02-11
@Nikepn911

The solution to the issue is here -
https://voyager-docs.devdojo.com/customization/ove... I figured it
out, found what I need in the documentation, you never know who will look - here is the solution, redefine the base model in the service provider, which Voyager uses, and then my refinement that I did above is NOT NEEDED AT ALL, everything will work like that!

S
Sergey delphinpro, 2021-02-11
@delphinpro

Have you tried just adding your user's namespace in the settings?
https://delphinpro.gitbook.io/voyager-en/getting-s...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question