જેમ જેમ Laravel એપ્લિકેશન વધે છે, તેમ તેમ ડિફૉલ્ટ "fat controller / fat model" અભિગમ જાળવવા માટે મુશ્કેલ બની જાય છે. મોટી એપ્લિકેશનો વધારાના આર્કિટેક્ચર સ્તરો — સેવા વર્ગો, ક્રિયા વર્ગો, રીપોઝીટરીઝ, ફોર્મ વિનંતીઓ, અને સ્પષ્ટ ડોમેન સંગઠન — માંથી લાભ મેળવે છે, જે ગતિશીલતાને સંગઠિત, પરીક્ષણીય અને જાળવણીયોગ્ય રાખે છે।
સમસ્યા: તર্ક ખોટી જગ્યાએ સમાપ્ત થાય છે
Small apps: logic in controllers and models is fine.
Large apps: controllers get bloated, models become "god objects", logic is duplicated
→ hard to test, maintain, and reason about. Extract logic into dedicated layers.
સેવા વર્ગો — ગતિશીલતાને એનક્યાપ્સુલેટ કરો
{
{}
{
DB::(function () ($, $) { /* ... */ });
}
}
{
->(->(), ->());
}
