81 lines
1.4 KiB
PHP
81 lines
1.4 KiB
PHP
<?php
|
|
|
|
use oauth2\models\IApi;
|
|
|
|
class Api extends Eloquent implements IApi {
|
|
|
|
protected $table = 'oauth2_api';
|
|
|
|
public function scopes()
|
|
{
|
|
return $this->hasMany('ApiScope','api_id');
|
|
}
|
|
|
|
public function resource_server()
|
|
{
|
|
return $this->belongsTo('ResourceServer');
|
|
}
|
|
|
|
public function endpoints()
|
|
{
|
|
return $this->hasMany('ApiEndpoint','api_id');
|
|
}
|
|
|
|
/**
|
|
* @return \oauth2\models\IResourceServer
|
|
*/
|
|
public function getResourceServer()
|
|
{
|
|
return $this->resource_server()->first();
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function getLogo()
|
|
{
|
|
return $this->logo;
|
|
}
|
|
|
|
|
|
public function getDescription()
|
|
{
|
|
return $this->description;
|
|
}
|
|
|
|
public function getScope()
|
|
{
|
|
$scope = '';
|
|
foreach($this->scopes()->get() as $s){
|
|
if(!$s->active) continue;
|
|
$scope = $scope .$s->name.' ';
|
|
}
|
|
$scope = trim($scope);
|
|
return $scope;
|
|
}
|
|
|
|
public function isActive()
|
|
{
|
|
return $this->active;
|
|
}
|
|
|
|
|
|
public function setName($name)
|
|
{
|
|
$this->name = $name;
|
|
}
|
|
|
|
|
|
|
|
public function setDescription($description)
|
|
{
|
|
$this->description = $description;
|
|
}
|
|
|
|
public function setStatus($active)
|
|
{
|
|
$this->active = $active;
|
|
}
|
|
} |