I have the following method in a Controller in Laravel 5.3.The method is supposed to be in two other controllers and all three Controller methods will receive the needed arguments in different ways.I'm unsure if this would be a good fit for a Service Container or how I should handle it.public function newSurvey(Request $request){    // Some validation for the input    $delay = 0;    if( $request->has('delay') ) {        $delay = $request->get('delay') * 60;    }    if($request->has('template')) {        $template = $this->application->templates()->where('slug', $request->get('template'))->first();    }    else    {        if(count($this->application->templates) == 0)        {            return response()->json(['error' => 'You need to create a Survey Template to send out new Surveys'], 422);        }        $template = $this->application->templates()->where('default', true)->first();    }    if(!$person = $this->application->persons->where('email', mb_strtolower($request->get('email')))->first())    {        $person = new Person();        $person->name = $request->get('name');        $person->email = mb_strtolower($request->get('email'));        $person->key = Uuid::uuid4()->toString();        $this->application->persons()->save($person);    }    if(!$person->active)    {        return response()->json(['error' => 'Recipient is inactive and cannot be contacted anymore'], 422);    }    if($person->updated_at->diffInDays(Carbon::now()) < $this->application->cooldown)    {        return response()->json(['error' => 'Recipient has already received a survey wihtin the cooldown period'], 422);    }    $person->touch();    $survey = new Survey([        'key' => Uuid::uuid4()->toString(),        'template_id' => $template->id,        'person_id' => $person->id,        'name' => $request->get('name', null),        'email' => $request->get('email'),        'order' => $request->get('order', null),        'segment' => $request->get('segment', null),    ]);    $this->application->surveys()->save($survey);    $when = \Carbon\Carbon::now()->addSeconds($delay);    Mail::to($survey->email, $survey->name)->later($when, new NewSurvey($survey));    return response()->json(['survey_id' => $survey->key], 200);}
Maintainability with lots of lookups, checks and inserts
php;laravel