Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

swgj32's avatar

How to setup Logic of Authentication and Database

Roles will be helpers, clients, admin. I need to know what type of database logic should be in place and what tables. I need to know what type of authorization or role system should be in place. Should it be multiple authentication or something else? How can I build this to integrate and android app later? Or should I just build the application and that can be done later? It will grow by city slowly. Is there a way to simplify the payment system with less steps? Any help in logic, database logic, and way to setup authentication is appreciated.

Client Posts Job

  1. Client will come to website and sign-up.
  2. Will provide job title, drop down category, description, and estimated # of hours for job.
  3. Client sees estimated cost to hire someone.

Client Looks for Helper

  1. Client will find/see helpers in zip code area
  2. Client will choose helper and hire or ask question before hire.
  3. If hired, helper is automatically hired and email notification sent to helper and client.
  4. Client contact info is shown to Helper.

Helper Finds Job

  1. Helper will come to website and sign-up.
  2. Helper will find/see jobs in zip code area and estimated hours and pay.
  3. Helper will apply for job or ask question.
  4. Helper will get job if chosen.
  5. If hired, helper is automatically hired and email notification sent to helper and client.
  6. Client contact info is shown to Helper.

Helper meets client in person.

  1. Job is completed
  2. Agreement by website that job is completed by helper and client.
  3. Helper is sent a job completion form in which helper has to mention number of hours taken for the job.
  4. A payment link will go to the client email stated that "Helper send you the invoice for x number of hours and total becomes x$, pay by clicking below PAY NOW button".
  5. Client will pay by Stripe and Helper gets the money.
  6. 30% cut of payment is sent to the website and 70% given to helper.
  7. If it is cash-out then helper is charged 30% of job total via stripe in account.
  8. If billing issue, then helpers website account is frozen.

Job will automatically close after x days of inactivity.

0 likes
4 replies
swgj32's avatar

Lol, yes, I tend to get ahead of myself. Thanks for that link. I have implemented the basic auth and it works for a user and admin. However, I need to setup and auth system where roles are defined e.i. buyer/seller/admin... Any advice on how to go about this?

santhusurya's avatar
Level 2

@swgj32 I hope you will have a user table defined with rolesassigned to each & every user.

Once the user is authenticated & before redirecting the user to a login success page, fetch the associated predefined roles of that user & based on that redirect the user to specific routes which a user can access but restricted with middleware.

Please follow the docs on Middleware

Create & register new Middlewares for each & every kind of user role & using middlewares you can implement role based user access in your app. Also you will have different routesdefined for each kind of user role.

Refer this Assigning Middleware To Routes

I'm using similar approach in my projects.

If my answer helped you, then please mark this answer as solution.

Please or to participate in this conversation.