To pluck the ids of all JobFunctions that a user has through the Job model, you can use the pluck method on the jobFunctions relationship of the Job model. Here's an example:
$user = User::find(5);
$jobFunctionIds = $user->jobs()->with('jobFunctions')->get()->pluck('jobFunctions.*.id')->flatten()->unique();
In this example, we first retrieve the user with ID 5. Then, we eager load the jobFunctions relationship on the jobs relationship. We use the pluck method to extract the id attribute from each jobFunction model. The * wildcard is used to indicate that we want to pluck the id attribute from all jobFunction models. Finally, we use the flatten and unique methods to remove any duplicates and return a collection of unique job function IDs.
Note that this solution assumes that the Job model has a jobFunctions relationship defined like this:
class Job extends Model
{
public function jobFunctions()
{
return $this->belongsToMany(JobFunction::class);
}
}