@vincent15000 from official docs (scroll down a little to addSelect section):
If you already have a query builder instance and you wish to add a column to its existing select clause, you may use the addSelect method:
But - you don't have select. So, it contains 1 value only.
By the way - your query looks wrong to my. you try to use eager loading by using with, but next line you join this table formation again. Possible something like that will make more sense
$alertes = Alerte::
with([
'salarie',
'formation' => function ($query) {
$query->select(['*', Db::raw('date_add(date_fin, interval duree_validite month) as date_recyclage')]);
})
])
->whereHas('formation' => function ($query) {
$query->where('entreprise_id', $this->entreprise_id)
})
->when($this->traitee, function ($query) {
$query->where('traitee', $this->traitee);
})
->orderByRaw($this->critere_tri, $this->asc ? 'asc' : 'desc')
->paginate($this->nombre_par_page);