ohtarr/service-now-model

此包最新版本(dev-master)没有提供许可证信息。

PHP7 Laravel5 组件,用于连接 ServiceNow 表格 API

dev-master 2021-09-09 19:22 UTC

This package is auto-updated.

Last update: 2024-09-09 00:42:20 UTC


README

一个用于访问 ServiceNow 表格 API 的 Laravel 模型

如果你使用这个...那就太疯狂了...绝对是精神病!:+1

需要 Laravel 5.x 和 GuzzleHttp

如何使用

在您的 Laravel .env 文件中设置以下变量

'SNOWBASEURL' = https://yourcompany.service-now.com/api/now/v1/table
'SNOWUSERNAME' =
'SNOWPASSWORD' =

在您的 Laravel 应用程序文件夹中为每个表创建一个新模型,并设置 $table。例如

ServiceNowIncident.php******

<?php

namespace App;

use ohtarr\ServiceNowModel;
use GuzzleHttp\Client as GuzzleHttpClient;

class ServiceNowIncident extends ServiceNowModel
{
    protected $guarded = [];

    public $table = "incident";

    public function __construct(array $attributes = [])
    {
        $this->snowbaseurl = env('SNOWBASEURL'); //https://mycompany.service-now.com/api/now/v1/table
        $this->snowusername = env("SNOWUSERNAME");
        $this->snowpassword = env("SNOWPASSWORD");
        parent::__construct($attributes);
    }

}

然后在您的应用程序中可以使用它

$incident = new App\ServiceNowIncident;
$incident->where("number","=","INC2321232")->get();

或者

$incident = App\ServiceNowIncident::where("number","=","INC2321232")->first()

或者

$incident = App\ServiceNowIncdient::find("1782fd1d6fcb87005d6dcd364b3ee4c1");

如果你够勇敢的话

$incidents = App\ServiceNowIncident::all();