mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 12:37:32 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			756 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			756 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| class IntegrationController extends Controller
 | |
| {
 | |
|     public function subscribe()
 | |
|     {
 | |
|         $eventId = Utils::lookupEventId(trim(Input::get('event')));
 | |
| 
 | |
|         if (!$eventId) {
 | |
|             return Response::json('', 500);
 | |
|         }
 | |
| 
 | |
|         $subscription = Subscription::where('account_id', '=', Auth::user()->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();
 | |
| 
 | |
|         return Response::json('{"id":'.$subscription->id.'}', 201);
 | |
|     }
 | |
| }
 |