public function get_services() { $userServices = UserService::where('user_id', '=', \Auth::user()->id)->get(); $services = array(); if ($userServices) { foreach ($userServices as $k => $service) { $key = $service->api[0]->id; $services[$key] = $service->api[0]->name; } } $arr = array_reverse($services, true); $arr[''] = 'Please Choose'; $services = array_reverse($arr, true); return $services; }
public function subscribe(Request $request) { $data = $request->all(); $rules = ['growpage' => 'required|exists:relink_snips,id']; $this->validate($request, $rules); $growPage_item = ReLinkSnips::find($data['growpage']); $api = Api::find($growPage_item['api']); $service = UserService::where(['user_id' => $growPage_item['user_id'], 'api_id' => $growPage_item['api']])->first(); $name = str_replace(' ', '', strtolower($api->name)); $this->{$name}($service, $data['email']); }