mercredi 25 octobre 2017

@include equivalent for controllers in Laravel

I have various controller functions where I have a large chunk of code (for an API call) which repeats in other functions a lot of time. Is there a @include equivalent to just copy/paste the codes in my controller. This will be much easier to read and follow through.

In my controller, something like this

    public function store () 
    {
       if ($company->name = 'XYX')
       {
           @include('xyzcontrollercode') 
       }

       if ($company->name = 'DEF')
       {
           @include('defcontrollercode') 
       }
   }

The includes - 'xyzcontrollercode' will have a large chunk of logic which will implement once the 'if' condition matches.

Any way to achieve this kind of functionality for controllers?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2yLvVer
via IFTTT

Aucun commentaire:

Enregistrer un commentaire