Q:

Laravel Query Builder result using join() query

The following query works fine, but the problem is that it gives the id of the events table instead of tasks table id in the output result. 
Task::join('events', function ($join) {
    $join->on('events.task_id', '=', 'tasks.id')
        ->where('events.event_type', '=', 'Task')
        ->where('events.task_stage', '!=', 'assigned');
})->select('tasks.*')
->get();

A:

Try this, one should work
->select('*', 'tasks.id as taskID')->get();

This is because maybe both tasks and events table have id field. So u need to use a separate query to specify the id.

