Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialneelraina
5,587 PointsCreate a 'pending approval' app object
Create a 'pending approval' app object
I am building a little app where a business owner assigns employees to a certain job. The employees will then have the option to accept or decline working on the job.
The status will be pending until the employee replies. If they reject it, the owner will invite another employee to work on the job.
I am quite stumped on how to do this. Among others, what tables should the βpendingβ statuses be held in, considering that they will only be temporary.
I am working with Laravel.
2 Answers
Tim Knight
28,888 PointsI'm only particularly familiar with Laravel, but perhaps I can at least help your thinking in the right direction.
I'm just kind of thinking out loud here... I don't necessarily think that the status of declined is temporary. What if you had a jobstatus stable that was essentially a join table between your job and your employee. This was you could see which employees declined the job before it was accepted. You could also right a method in your job model that would take the relationship to see if the job itself had been accepted (by checking to see if any of the users it had been sent to approved it). Does that help? If you're not wanting to keep any of that history that you could just keep the status on the job itself, but you'd want to know which users it had already been sent to so the same people don't continue to get the request and decline it.
Ted Sumner
Courses Plus Student 17,967 PointsI think this is really a database project. Each employee would be in a table with a unique identifier. Each task would be in a table with a unique identifier. This is where I run into the limitations of my database structure work. I think you would have a table that links a task to an employee who was invited to that task. Then you would have a table with the result (accept or decline). If it is in the invite table but not the result, it would be pending. You would then use PHP to process all of the information.