You cannot make table width make dynamic based on maximal count of $tugas, that is excel way of duing things. If you now that max 3 items are in relationship why use one column and add it to it...
You can also adjust main query to calculate that column, or have virtual sql column or sql view, or havinng job to calculate that column from time to time