Laravel hasManyThrough

There is the useful hasManyThrough in Eloquent in which you can you 3 Tables and define which keys to use to join them.

Laravels example and documentation can be found here .
There is a little detail problem with it, it is all called id and the example wasn’t helping me much.

I have the following tables to handle job applications to jobs
Jobs
– id
– title
– description

Users
– id
– firstname
– lastname

Application
– id
– user_id
– job_id
– application_date

In the jobsmodel I want to get a list of all applicants.
Here is the first version of this

public function applicants(): HasManyThrough
{
    return $this->hasManyThrough(
        'App\Models\User',
        'App\Models\Application',
        'job_id',
        'id',
        'id',
        'id'
    );
}

While testing I received some strange applicants which never applied for the job.

After debugging I found that the last 'id' uses job.id to load the users with user.id. Bug found.
It should really be application.user_id to load the correct users. So a small change to this:

public function applicants(): HasManyThrough
{
    return $this->hasManyThrough(
        'App\Models\User',
        'App\Models\Application',
        'job_id', // (application.job_id)
        'id', // Foreign key on User table (user.id)
        'id', // Local key on job table (job.id)
        'user_id' // Local key on Application table (application.user_id)
    );
}

So changing the last id to user_id fixed that bug.

Dear Linked-In Recruiter

I receive job-offerings on a regular basis. That is really nice you’ve contacted me, but you need to stand out with your texts. And also: I’m not interested.

Most of the time it feels like spam receiving these template letters from people not knowing the industry or not knowing what a programming language is.

Even if the offer might be interesting in the end, I am not interested for some of the following reasons:

  • Wrong or lazy written templates
    • You’re using a template in which the salutation isn’t spelled out (German: Sg. instead of Sehr geehrter Herr …)
    • Any kind of typing errors
    • Leaving your placeholders in your template
    • MfG instead of “Mit freundlichem Gruss”
    • A really long text with no real value or information
  • Tell me more about your “intersting” projects, company culture, top equipment and so on
    • You want to convince me to switch companies with your interesting project might takes more information about the project. I might be heavily into CMS/PIM/DAM systems or backends and you are offering me a position in a company that only does e-commerce frontend work. I don’t want to invest time in such inapt jobs
    • What does the project might have that I’m interested in? Tell me about that in advance.
    • Anything related to company culture should be more than just mentioning it. Does the company have non-work related activities, regular feedbacks, code reviews and their like
    • Equipment is nice to have but I need to feel comfortable with it. You don’t know what type of equipment I like, but on the other hand you keep telling me it is top equipment…
  • Company pays for a moving costs
    • If I already told you that I’m not interested in moving it doesn’t make it more attractive in telling me the company will pay for a move
  • Offering me jobs with wrong programming languages
    • Tells me: you don’t understand your job and you don’t know what I am offering or your client is looking for and therefore wasting my and your clients time
  • Contacting me shortly after job change
    • I’ve changed my job, why should I be interested in joining your clients company? Ever thought about that the change might happened for a reason and I’ve already decided to work for a company

I think this is sort of annoying to get contacted with this kind of letters. I, as an employee trying to get to an interview, need to write a promotion letter, send a whole lot of information about my live, projects, reports and so on.

But you, as a recruiter contacting me, are allowed to just say “hi”? Sorry but I don’t like how this works. Either both of us are allowed to just say “hi” or we both stick to full reports, projects list etc.