Beautiful.
And once we're done, we check permissions functionality before we rush over to the front end and start
implementing it.
Why don't we complete everything here in the jobs controller?
Meaning why don't we also complete the delete job functionality?
Since that way, we can set up both of them right away in the frontend.
So I'm like going back and front and back and front.
And in this case, why don't we complete the delayed job functionality as well?
And then we'll implement both of them on the front end.
It just seems like less of a switching, and essentially it's going to be extremely, extremely, extremely
similar to that of the added jump.
In this case, we just don't need to check for company position.
We'll still check for Javadi, which is going to be in the params will still look for a job based on
the ID.
If the job doesn't exist, then we throw the error.
And then, of course, again, we want to check for the permissions.
And then instead of find one and remove, I'm just going to go with a weight and job.
So this is another instance method that we can use.
So previously I showed you a job that say unless there's job job there and we just invoke it online.
Essentially, front end is not going to be looking for any kind of data.
We simply want to send back some kind of message for the postman.
As far as the front end, it will right away, no, whether we were successful or not.
So let's start working on that.
And I mean, just navigate to delete.
Job over here.
And you know what?
In order to speed things up, I will grab some things from the job.
I really don't see the point of reusing them.
So let's go over here where we have the lead job.
Let's grab the parameter first.
Then, like I said, we're not looking for position, company or job location for that matter.
And you're not may actually remove it from here as well.
I just want to grab the job and if the job doesn't exist, then I want to throw the error.
I actually want to remove these consumer logs.
We're not going to need them anymore.
So let's scroll where we have the lead job and also we can ride away, check the permission.
So check the permissions.
That's the cool thing.
If you set it up as a function and you can just invoke the function, both things are going to be exactly
the same redirect that the user as well as job created by and then as far as the response.
Well, before we can do anything, we want to remove the job.
So if everything is correct, we go with job and then Darth Remove, we invoke that and then let's send
the rats that status.
So that is going to be status code and not OK.
And then, like I said, just for the postman purposes.
We're going to go, Jason.
And let's pass in the message.
And here we're looking for the success.
And let's go with Jobberman.
Again, it's not going to show up anywhere on the front end job and.
Let's save us.
Let's remove the rats, not stand.
Now, of course, we can test that out and navigate back to the post, man.
I'll leave this one the way it is, and let's try to do that with the beta.
Remember, we are logged in as beta, while at least I am.
So let me go to the lead job, and if everything is correct, I shouldn't be successful because the
job does not belong to Peter and I can clearly see my 401, which is just awesome.
So now let me go back to the logging and logging as John.
Let's send it here.
Get back to response, and now when it comes to the leading job.
Let me first double check, so it's definitely the case, so I'm going to get all my jobs.
And let's go with this one.
While this works and let's see whether I am successful, the job and if everything is correct, I should
see the success message.
Copy and paste and you have jobs removed.
Now, if I go back to all my jobs now, I should have only five.
And with this in place now I can implement both the edit one as well as delete one on the frontend.