Inheritance: extends Illuminate\Database\Eloquent\Model
Ejemplo n.º 1
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('integrations', function ($id) use($router) {
         $user = \Auth::user();
         return Integration::whereUserId($user->id)->whereId($id)->firstOrFail();
     });
     $router->bind('monitors', function ($uuid) {
         return Monitor::where('uuid', $uuid)->firstOrFail();
     });
     parent::boot($router);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = $request->all();
     $existing = Integration::where(['api_type' => $request->api_type])->get();
     $existing = isset($existing[0]) ? $existing[0] : null;
     if ($existing) {
         $existing->fill($input)->save();
     } else {
         Integration::create($input);
     }
     return $this->index();
 }
Ejemplo n.º 3
0
 /**
  * Get the api class name
  *
  * @param  [string] $type [description]
  * @return [type]       [description]
  */
 public static function getApi($type)
 {
     $integration = Integration::where(['api_type' => $type])->get();
     if ($integration) {
         $apiConfig = $integration[0];
         $className = $apiConfig->name;
         call_user_func_array(['App\\' . $className, 'initialize'], [$apiConfig]);
         $apiInstance = call_user_func_array(['App\\' . $className, 'getInstance'], []);
         return $apiInstance;
     }
     throw new \Exception('The user has no integrated APIs');
 }
Ejemplo n.º 4
0
 public function invoice($id, $requestData)
 {
     $contatGuid = $requestData->invoiceContact;
     $taskname = Tasks::find($id);
     $timemanger = TaskTime::where('fk_task_id', $id)->get();
     $sendMail = $requestData->sendMail;
     $productlines = [];
     foreach ($timemanger as $time) {
         $productlines[] = array('Description' => $time->title, 'Comments' => $time->comment, 'BaseAmountValue' => $time->value, 'Quantity' => $time->time, 'AccountNumber' => 1000, 'Unit' => 'hours');
     }
     $api = Integration::getApi('billing');
     $results = $api->createInvoice(['Currency' => 'DKK', 'Description' => $taskname->title, 'contactId' => $contatGuid, 'ProductLines' => $productlines]);
     if ($sendMail == true) {
         $bookGuid = $booked->Guid;
         $bookTime = $booked->TimeStamp;
         $api->sendInvoice($bookGuid, $bookTime);
     }
 }
Ejemplo n.º 5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param Integration $integration
  * @return \Illuminate\Http\Response
  * @throws \Exception
  */
 public function destroy(Integration $integration)
 {
     $integration->delete();
     return redirect(route('account.integrations.index'));
 }
Ejemplo n.º 6
0
 public function invoice($id, Request $request)
 {
     $task = Tasks::findOrFail($id);
     $clientId = $task->clientAssignee()->first()->id;
     $timeTaskId = $task->allTime()->get();
     $integrationCheck = Integration::first();
     if ($integrationCheck) {
         $this->tasks->invoice($id, $request);
     }
     $this->invoices->create($clientId, $timeTaskId, $request->all());
     Session()->flash('flash_message', 'Invoice created');
     return redirect()->back();
 }