I am running this query:
TaskNote::select(['id AS task_note_id', 'task_id', 'added_by ', 'note'])
->join('tasks', 'tasks.id', '=', 'task_notes.task_id')
->where('tasks.user_id', auth()->id())
->orWhere('tasks.created_by', auth()->id())
->orWhere('tasks.reviewer_id', auth()->id())
->get();
but for some reason, in the result the task_notes.id is replaces by the task.id. I've tried also to set the field like task_notes.id AS task_note_id, but in this case task_note_id is missing from the result and again the task_note.id is replaced by the task.id
This is one of the results:
Illuminate\Database\Eloquent\Collection {#2867 ▼ // app\Livewire\Task\TasksNotes.php:44
#items: array:15 [▼
0 =>
App\Models
\
TaskNote {#2869 ▼
#connection: "mysql"
#table: "task_notes"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
+preventsLazyLoading: true
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#escapeWhenCastingToString: false
#attributes: array:25 [▼
"id" => "9e0e16a4-9faa-4a67-950c-ff8314d21e96"
"task_id" => "9e0e16a4-9faa-4a67-950c-ff8314d21e96"
"added_by" => "9e0e0e5c-4e62-424d-a012-7853f1ce0efa"
"note" => "test note"
]
#original: array:25 [▼
"id" => "9e0e16a4-9faa-4a67-950c-ff8314d21e96"
"task_id" => "9e0e16a4-9faa-4a67-950c-ff8314d21e96"
"added_by" => "9e0e0e5c-4e62-424d-a012-7853f1ce0efa"
"note" => "test note"
]