Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
OrmAuth Categories in scaffolded Admin controller
  • Hi there,

    This seems like a really simple question but I can't figure it out. What does the '6' in the following line in the scaffolded admin controller mean? :
    $admin_group_id = Config::get('auth.driver', 'Simpleauth') == 'Ormauth' ? 6 : 100;

    I'm guessing the '100' refers to the user group 'Administrators' found in:
    fuel/packages/auth/config/simpleauth.php

    So I checked ormauth.php in the same location but could not find a reference. The reason I want to know is because I want to create two different dashboards. One for administrators and another one for regular users.

    Thanks for your time.
  • The 6 is the ID of the group 'admin' when you run the migrations for ORMAuth. You won't find this number anywhere in any php-file because it is inside your database (check table `users_groups` for the row of group 'admin', then see its ID).
  • I'm a beginner at PHP and MVC frameworks let alone FuelPHP. I've followed this guide.

    I don't have such a table.

    1) Is it because I'm using 'SimpleAuth'?
    2) And also, am I right about the '100'?
    3) If I don't have the table, can I simply the query mentioned in my first post?

    Thanks
  • You probably don't have the table because you haven't run the Auth migrations, which will create the required tables using your db config and your auth config.

    From the root of your installation, run

    php oil refine migrate --all
  • Thanks a lot for the replies so far.

    @ Harro Verton,
    That was, what was missing. Unfortunately, I'm still not getting the table philipptempel mentioned (users_groups). My table list after executing the command can be found here.
  • users_groups is an Ormauth table.

    If you haven't configured that (up front), you won't get those tables. If you want to use Ormauth instead, you have to reverse your migrations:

    php oil refine migrate:down --packages=auth

    and repeat that until all migrations are reversed.

    Then copy fuel/packages/auth/config/auth.php to fuel/app/config and modify it with your settings ('ormauth' as driver, enter your random password salt, etc).

    After that, run your migrations again.
  • Okay, just one final confirmation. I've decided to keep it simple and just use 'SimpleAuth' for now until I've gotten a stronger hold on fuelphp.

    So does this mean that I can replace the following:
    $admin_group_id = Config::get('auth.driver', 'Simpleauth') == 'Ormauth' ? 6 : 100;

    with:
    $admin_group_id = 100;


    Thanks.
  • Yes.

    It also means you have to change all your code when you switch to Ormauth later, which is why it is coded this way. ;-)
  • Thanks so far. Just one more clarification, please :)

    Now, I wish to code conveniently as you mentioned and I want to introduce regular users along with administrators. I've set the variables in the 'SimpleAuth'; 100 for administrators and 1 for regular users. And I understand where I can put these variables in the condition but what about the values for 'OrmAuth', where can I view all of them so I can program them?
  • HarroHarro
    Accepted Answer
    The Ormauth default groups are created here: https://github.com/fuel/auth/blob/1.8/develop/migrations/005_auth_create_authdefaults.php#L29

    So:
    1 - Banned
    2 - Guest
    3 - Users
    4- Moderators
    5 - Admins
    6- Superadmins

    Note that these are only defaults. You don't have to use them.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion