jeudi 22 septembre 2016

Using functions within a Laravel controller

I have a standard laravel controller function with over 350 lines of logic for a number of different on-page elements. Some of the logic could be taken out put within it's own function but I would need to pass the variables back to the laravel controller to be used within a view.

Does laravel recommend any standards for this? or can I create a function within a controller and just pass the final variables back as I would in php?

Example of controller -

class PubsController extends Controller
{
    public function getIndex()
    {
        //Date Helpers
        $dateThisMonth = Carbon::now()->startOfMonth()->toDateString();
        $dateLastMonth = Carbon::now()->subMonth()->startOfMonth()->toDateString();
        $dateNextMonth = Carbon::now()->addMonth()->startOfMonth()->toDateString();
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire