dimanche 1 novembre 2015

Secure and clean code in laravel 5.1

In fact i have a question about the clean of code
i try to get some value in blade file , I Am confused between two approaches i think both are right but i need to know who's clean and secure more with the reason

First approach in my blade directly using Eloquent

@foreach (Auth::user()->company->country->cities as $city) {{$city->name}} @endforeach

Second approach using Injecting Services by create this method in my model and use it in my blade using laravel 5.1 Injecting Services

 public function getCity()
{
    foreach(Auth::user()->company->country->cities as $city) {
        return $city->name ;
    }
}

Thanks For Your Time .



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire