jeudi 15 septembre 2016

Different css for different company - Laravel

I've made a website which has 1 design. There could be users with different roles. Roles are next :

  • normal user
  • admin of company
  • worker
  • ...

Each user on website has his company (in database its integer field) and i would like to make that each user with role - admin of company can change design of website for his company (for start colors of body, header, footer etc.). Example of that is that company 1 has yellow design, company 2 red etc. So far i have come up with idea to do it like this:

In table company expand table schema for additional columns (body_color-string, footer_color-string etc) and write values for each company into database.

After user is successfully logged then those values load from database in session and in my app.blade.php override css sections with session ones.

For example if i have div

<div class="test123">Something</div> 

I would override that value in my app.blade.php, if session is not set then apply default color white.

<style>
    .test123 {
        background-color:}
</style>

And this works, but it's kinda messy, so i would ask for some advice or improvement for later on (when i will have maybe height, width of some elements, etc)...

Am i doing it the right way, or this can be done even easier?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire