Actually, I have a question about clean code,
I'm trying to get some value in a blade server file , I get confused between the two approaches, I think both of them are right, but I need to know who is clean and protected more by reason
The first approach in my blade directly using Eloquent
@foreach
(Auth::user()->company->country->cities as $city) {{$city->name}}
@endforeach
The second approach using Injecting Services, create this method in my model and use it in my client using laravel 5.1 Injecting Services
public function getCity()
{
foreach(Auth::user()->company->country->cities as $city) {
return $city->name ;
return $city ;
}
}
Thank you for your time.
source
share