account_id) ->where('event_id', '=', $eventId)->first(); if (!$subscription) { $subscription = new Subscription(); $subscription->account_id = Auth::user()->account_id; $subscription->event_id = $eventId; } $subscription->target_url = trim(Input::get('target_url')); $subscription->save(); if (!$subscription->id) { return Response::json('Failed to create subscription', 500); } return Response::json(['id' => $subscription->id], 201); } }