code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
protected function setCreatedAuthorizer($resourceType, ?AuthorizerInterface $authorizer = null)
{
$this->createdAuthorizers[$resourceType] = $authorizer;
}
|
@param string $resourceType
@param AuthorizerInterface|null $authorizer
@return void
|
setCreatedAuthorizer
|
php
|
cloudcreativity/laravel-json-api
|
src/Container.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Container.php
|
Apache-2.0
|
protected function create(?string $className)
{
if (false === $this->exists($className)) {
return null;
}
try {
$value = $this->container->make($className);
} catch (BindingResolutionException $ex) {
throw new RuntimeException(
sprintf('JSON:API container was unable to build %s via the service container.', $className),
0,
$ex,
);
}
if ($value instanceof ContainerAwareInterface) {
$value->withContainer($this);
}
return $value;
}
|
@param string|null $className
@return mixed|nulL
|
create
|
php
|
cloudcreativity/laravel-json-api
|
src/Container.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Container.php
|
Apache-2.0
|
protected function exists(?string $className): bool
{
if (null === $className) {
return false;
}
return class_exists($className) || $this->container->bound($className);
}
|
@param string|null $className
@return bool
|
exists
|
php
|
cloudcreativity/laravel-json-api
|
src/Container.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Container.php
|
Apache-2.0
|
public static function defaultApi(string $name): self
{
if (empty($name)) {
throw new \InvalidArgumentException('Default API name must not be empty.');
}
self::$defaultApi = $name;
return new self();
}
|
Set the default API name.
@param string $name
@return LaravelJsonApi
|
defaultApi
|
php
|
cloudcreativity/laravel-json-api
|
src/LaravelJsonApi.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/LaravelJsonApi.php
|
Apache-2.0
|
public function register()
{
$this->bindNeomerx();
$this->bindService();
$this->bindInboundRequest();
$this->bindRouteRegistrar();
$this->bindApiRepository();
$this->bindExceptionParser();
$this->bindRenderer();
}
|
Register JSON API services.
@return void
|
register
|
php
|
cloudcreativity/laravel-json-api
|
src/ServiceProvider.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/ServiceProvider.php
|
Apache-2.0
|
protected function bootMiddleware(Router $router)
{
$router->aliasMiddleware('json-api', BootJsonApi::class);
$router->aliasMiddleware('json-api.content', NegotiateContent::class);
$router->aliasMiddleware('json-api.auth', Authorize::class);
}
|
Register package middleware.
@param Router $router
|
bootMiddleware
|
php
|
cloudcreativity/laravel-json-api
|
src/ServiceProvider.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/ServiceProvider.php
|
Apache-2.0
|
protected function bindNeomerx(): void
{
$this->app->singleton(Factory::class);
$this->app->alias(Factory::class, FactoryInterface::class);
$this->app->bind(
\Neomerx\JsonApi\Contracts\Http\Headers\HeaderParametersParserInterface::class,
\Neomerx\JsonApi\Http\Headers\HeaderParametersParser::class,
);
}
|
Bind parts of the neomerx/json-api dependency into the service container.
For this Laravel JSON API package, we use our extended JSON API factory.
This ensures that we can override any parts of the Neomerx JSON API package
that we want.
@return void
|
bindNeomerx
|
php
|
cloudcreativity/laravel-json-api
|
src/ServiceProvider.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/ServiceProvider.php
|
Apache-2.0
|
protected function bindService()
{
$this->app->singleton(JsonApiService::class);
$this->app->alias(JsonApiService::class, 'json-api');
$this->app->alias(JsonApiService::class, 'json-api.service');
}
|
Bind the JSON API service as a singleton.
|
bindService
|
php
|
cloudcreativity/laravel-json-api
|
src/ServiceProvider.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/ServiceProvider.php
|
Apache-2.0
|
protected function bindRouteRegistrar()
{
$this->app->alias(JsonApiRegistrar::class, 'json-api.registrar');
}
|
Bind an alias for the route registrar.
|
bindRouteRegistrar
|
php
|
cloudcreativity/laravel-json-api
|
src/ServiceProvider.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/ServiceProvider.php
|
Apache-2.0
|
protected function bindInboundRequest(): void
{
$this->app->singleton(Route::class, function (Application $app) {
return new Route(
$app->make(ResolverInterface::class),
$app->make('router')->current()
);
});
$this->app->singleton(StoreInterface::class, function () {
return json_api()->getStore();
});
$this->app->singleton(ResolverInterface::class, function () {
return json_api()->getResolver();
});
$this->app->singleton(ContainerInterface::class, function () {
return json_api()->getContainer();
});
$this->app->bind(HeaderParametersParserInterface::class, HeaderParametersParser::class);
$this->app->scoped(HeaderParametersInterface::class, function (Application $app) {
/** @var HeaderParametersParserInterface $parser */
$parser = $app->make(HeaderParametersParserInterface::class);
/** @var ServerRequestInterface $serverRequest */
$serverRequest = $app->make(ServerRequestInterface::class);
return $parser->parse($serverRequest, http_contains_body($serverRequest));
});
$this->app->scoped(QueryParametersInterface::class, function (Application $app) {
/** @var QueryParametersParserInterface $parser */
$parser = $app->make(QueryParametersParserInterface::class);
return $parser->parseQueryParameters(
request()->query()
);
});
$this->app->scoped(QueryParametersParserInterface::class, QueryParametersParser::class);
}
|
Bind the inbound request services so they can be type-hinted in controllers and authorizers.
@return void
|
bindInboundRequest
|
php
|
cloudcreativity/laravel-json-api
|
src/ServiceProvider.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/ServiceProvider.php
|
Apache-2.0
|
protected function bindApiRepository()
{
$this->app->singleton(Repository::class);
}
|
Bind the API repository as a singleton.
|
bindApiRepository
|
php
|
cloudcreativity/laravel-json-api
|
src/ServiceProvider.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/ServiceProvider.php
|
Apache-2.0
|
protected function bindExceptionParser()
{
$this->app->singleton(ExceptionParserInterface::class, ExceptionParser::class);
$this->app->alias(ExceptionParserInterface::class, 'json-api.exceptions');
}
|
Bind the exception parser into the service container.
|
bindExceptionParser
|
php
|
cloudcreativity/laravel-json-api
|
src/ServiceProvider.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/ServiceProvider.php
|
Apache-2.0
|
protected function bindRenderer()
{
$this->app->singleton(Renderer::class);
$this->app->alias(Renderer::class, 'json-api.renderer');
}
|
Bind the view renderer into the service container.
|
bindRenderer
|
php
|
cloudcreativity/laravel-json-api
|
src/ServiceProvider.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/ServiceProvider.php
|
Apache-2.0
|
protected function getConfig($key, $default = null)
{
$key = sprintf('%s.%s', 'json-api', $key);
return config($key, $default);
}
|
@param $key
@param $default
@return array
|
getConfig
|
php
|
cloudcreativity/laravel-json-api
|
src/ServiceProvider.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/ServiceProvider.php
|
Apache-2.0
|
protected function findToOne(array $relationship)
{
return $this->getStore()->findToOne($relationship);
}
|
Find the related record for a to-one relationship.
@param array $relationship
@return mixed|null
|
findToOne
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/AbstractRelationshipAdapter.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/AbstractRelationshipAdapter.php
|
Apache-2.0
|
protected function deserialize(array $document, $record = null): ResourceObject
{
$data = $document['data'] ?? [];
if (!is_array($data) || empty($data)) {
throw new \InvalidArgumentException('Expecting a JSON API document with a data member.');
}
return ResourceObject::create($data);
}
|
Deserialize a resource object from a JSON API document.
@param array $document
@param mixed|null $record
@return ResourceObject
|
deserialize
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/AbstractResourceAdapter.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/AbstractResourceAdapter.php
|
Apache-2.0
|
protected function isFillableRelation($field, $record)
{
return $this->isRelation($field) && $this->isFillable($field, $record);
}
|
Is the field a fillable relation?
@param $field
@param $record
@return bool
|
isFillableRelation
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/AbstractResourceAdapter.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/AbstractResourceAdapter.php
|
Apache-2.0
|
protected function methodForRelation($field)
{
if (method_exists($this, $field)) {
return $field;
}
$method = Str::camelize($field);
return method_exists($this, $method) ? $method : null;
}
|
Get the method name on this adapter for the supplied JSON API field.
By default we expect the developer to be following the PSR1 standard,
so the method name on the adapter should use camel case.
However, some developers may prefer to use the actual JSON API field
name. E.g. they could use `user_history` as the JSON API field name
and the method name.
Therefore we return the field name if it exactly exists on the adapter,
otherwise we camelize it.
A developer can use completely different logic by overloading this
method.
@param string $field
the JSON API field name.
@return string|null
the adapter's method name, or null if none is implemented.
|
methodForRelation
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/AbstractResourceAdapter.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/AbstractResourceAdapter.php
|
Apache-2.0
|
protected function fill($record, ResourceObject $resource, QueryParametersInterface $parameters)
{
$this->fillAttributes($record, $resource->getAttributes());
$this->fillRelationships($record, $resource->getRelationships(), $parameters);
}
|
Fill the domain record with data from the supplied resource object.
@param $record
@param ResourceObject $resource
@param QueryParametersInterface $parameters
@return void
|
fill
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/AbstractResourceAdapter.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/AbstractResourceAdapter.php
|
Apache-2.0
|
protected function fillRelationships(
$record,
Collection $relationships,
QueryParametersInterface $parameters
) {
$relationships->filter(function ($value, $field) use ($record) {
return $this->isFillableRelation($field, $record);
})->each(function ($value, $field) use ($record, $parameters) {
$this->fillRelationship($record, $field, $value, $parameters);
});
}
|
Fill relationships from a resource object.
@param $record
@param Collection $relationships
@param QueryParametersInterface $parameters
@return void
|
fillRelationships
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/AbstractResourceAdapter.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/AbstractResourceAdapter.php
|
Apache-2.0
|
protected function fillRelationship(
$record,
$field,
array $relationship,
QueryParametersInterface $parameters
) {
$relation = $this->getRelated($field);
$relation->update($record, $relationship, $parameters);
}
|
Fill a relationship from a resource object.
@param $record
@param $field
@param array $relationship
@param QueryParametersInterface $parameters
|
fillRelationship
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/AbstractResourceAdapter.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/AbstractResourceAdapter.php
|
Apache-2.0
|
protected function fillRelated($record, ResourceObject $resource, QueryParametersInterface $parameters)
{
// no-op
}
|
Fill any related records that need to be filled after the primary record has been persisted.
E.g. this is useful for hydrating many-to-many Eloquent relations, where `$record` must
be persisted before the many-to-many database link can be created.
@param $record
@param ResourceObject $resource
@param QueryParametersInterface $parameters
|
fillRelated
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/AbstractResourceAdapter.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/AbstractResourceAdapter.php
|
Apache-2.0
|
protected function fillAndPersist(
$record,
ResourceObject $resource,
QueryParametersInterface $parameters,
$updating
) {
$this->fill($record, $resource, $parameters);
if ($result = $this->beforePersist($record, $resource, $updating)) {
return $result;
}
$async = $this->persist($record);
if ($async instanceof AsynchronousProcess) {
return $async;
}
$this->fillRelated($record, $resource, $parameters);
if ($result = $this->afterPersist($record, $resource, $updating)) {
return $result;
}
return $record;
}
|
@param mixed $record
@param ResourceObject $resource
@param QueryParametersInterface $parameters
@param bool $updating
@return AsynchronousProcess|mixed
|
fillAndPersist
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/AbstractResourceAdapter.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/AbstractResourceAdapter.php
|
Apache-2.0
|
private function beforePersist($record, ResourceObject $resource, $updating)
{
return $this->invokeMany([
'saving',
$updating ? 'updating' : 'creating',
], $record, $resource);
}
|
@param $record
@param ResourceObject $resource
@param $updating
@return AsynchronousProcess|null
|
beforePersist
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/AbstractResourceAdapter.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/AbstractResourceAdapter.php
|
Apache-2.0
|
private function afterPersist($record, ResourceObject $resource, $updating)
{
return $this->invokeMany([
$updating ? 'updated' : 'created',
'saved',
], $record, $resource);
}
|
@param $record
@param ResourceObject $resource
@param $updating
@return AsynchronousProcess|null
|
afterPersist
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/AbstractResourceAdapter.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/AbstractResourceAdapter.php
|
Apache-2.0
|
protected function isFindMany(Collection $filters)
{
if (!$key = $this->filterKeyForIds()) {
return false;
}
return $filters->has($key);
}
|
Do the filters contain a `find-many` parameter?
@param Collection $filters
@return bool
|
isFindMany
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/Concerns/FindsManyResources.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/Concerns/FindsManyResources.php
|
Apache-2.0
|
protected function filterKeyForIds(): ?string
{
$key = property_exists($this, 'findManyFilter') ? $this->findManyFilter : null;
return $key ?: DocumentInterface::KEYWORD_ID;
}
|
Get the filter key that is used for a find-many query.
@return string|null
|
filterKeyForIds
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/Concerns/FindsManyResources.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/Concerns/FindsManyResources.php
|
Apache-2.0
|
protected function deserializeIdFilter($resourceIds): array
{
if (is_string($resourceIds)) {
$resourceIds = explode(',', $resourceIds);
}
if (!is_array($resourceIds)) {
throw new InvalidArgumentException('Expecting a string or array.');
}
return $this->databaseIds((array) $resourceIds);
}
|
Normalize the id filter.
The id filter can either be a comma separated string of resource ids, or an
array of resource ids.
@param array|string|null $resourceIds
@return array
|
deserializeIdFilter
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/Concerns/FindsManyResources.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/Concerns/FindsManyResources.php
|
Apache-2.0
|
protected function databaseIds(iterable $resourceIds): array
{
return collect($resourceIds)->map(function ($resourceId) {
return $this->databaseId($resourceId);
})->all();
}
|
Convert resource ids to database ids.
@param iterable $resourceIds
@return array
|
databaseIds
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/Concerns/FindsManyResources.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/Concerns/FindsManyResources.php
|
Apache-2.0
|
protected function databaseId(string $resourceId)
{
return $resourceId;
}
|
Convert a resource id to a database id.
Child classes can overload this method if they need to perform
any logic to convert a resource id to a database id.
@param string $resourceId
@return mixed
|
databaseId
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/Concerns/FindsManyResources.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/Concerns/FindsManyResources.php
|
Apache-2.0
|
protected function isFillable($field, $record)
{
/** If the field is listed in the fillable fields, it can be filled. */
if (in_array($field, $fillable = $this->getFillable($record))) {
return true;
}
/** If the field is listed in the guarded fields, it cannot be filled. */
if ($this->isGuarded($field, $record)) {
return false;
}
/** Otherwise we can fill if everything is fillable. */
return empty($fillable);
}
|
Is the JSON API field allowed to be filled into the supplied record?
@param $field
@param $record
@return bool
|
isFillable
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/Concerns/GuardsFields.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/Concerns/GuardsFields.php
|
Apache-2.0
|
protected function isNotFillable($field, $record)
{
return !$this->isFillable($field, $record);
}
|
Is the JSON API field not allowed to be filled into the supplied record?
@param $field
@param $record
@return bool
|
isNotFillable
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/Concerns/GuardsFields.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/Concerns/GuardsFields.php
|
Apache-2.0
|
protected function isGuarded($field, $record)
{
return in_array($field, $this->getGuarded($record));
}
|
Is the JSON API field to be ignored when filling the supplied record?
@param $field
@param $record
@return bool
|
isGuarded
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/Concerns/GuardsFields.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/Concerns/GuardsFields.php
|
Apache-2.0
|
protected function getFillable($record)
{
return $this->fillable;
}
|
Get the JSON API fields that are allowed to be filled into a record.
@param $record
@return string[]
|
getFillable
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/Concerns/GuardsFields.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/Concerns/GuardsFields.php
|
Apache-2.0
|
protected function getGuarded($record)
{
return $this->guarded;
}
|
Get the JSON API fields to skip when filling the supplied record.
@param $record
@return string[]
|
getGuarded
|
php
|
cloudcreativity/laravel-json-api
|
src/Adapter/Concerns/GuardsFields.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Adapter/Concerns/GuardsFields.php
|
Apache-2.0
|
public function __construct(
Factory $factory,
AggregateResolver $resolver,
string $name,
Url $url,
Config $config
) {
$this->factory = $factory;
$this->resolver = $resolver;
$this->name = $name;
$this->url = $url;
$this->config = $config;
}
|
Api constructor.
@param Factory $factory
@param AggregateResolver $resolver
@param string $name
@param Url $url
@param Config $config
|
__construct
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function getResolver()
{
return $this->resolver;
}
|
Get the resolver for the API and packages.
@return ResolverInterface
|
getResolver
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function getDefaultResolver()
{
return $this->resolver->getDefaultResolver();
}
|
Get the API's resolver.
@return ResolverInterface
|
getDefaultResolver
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function getDefaultCodec(): Codec
{
return $this->factory->createCodec(
$this->getContainer(),
$this->getEncodings()->find(MediaTypeInterface::JSON_API_MEDIA_TYPE) ?: Encoding::jsonApi(),
$this->getDecodings()->find(MediaTypeInterface::JSON_API_MEDIA_TYPE)
);
}
|
Get the default API codec.
@return Codec
|
getDefaultCodec
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function getResponses()
{
if (!$this->responses) {
$this->responses = $this->response();
}
return $this->responses;
}
|
Get the responses instance for the API.
@return Responses
|
getResponses
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function getConnection(): ?string
{
return $this->config->dbConnection();
}
|
Get the default database connection for the API.
@return string|null
|
getConnection
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function hasTransactions(): bool
{
return $this->config->dbTransactions();
}
|
Are database transactions used by default?
@return bool
|
hasTransactions
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function exceptions(): ExceptionParserInterface
{
return app(ExceptionParserInterface::class);
}
|
@return ExceptionParserInterface
@todo add this to config.
|
exceptions
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function encoder($options = 0, $depth = 512)
{
if ($options instanceof Encoding) {
$options = $options->getOptions();
}
if (!$options instanceof EncoderOptions) {
$options = new EncoderOptions($options, $this->getUrl()->toString(), $depth);
}
return $this->factory
->createLaravelEncoder($this->getContainer())
->withEncoderOptions($options);
}
|
Create an encoder for the API.
@param int|EncoderOptions|Encoding $options
@param int $depth
@return SerializerInterface
|
encoder
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function response()
{
return $this->factory->createResponseFactory($this);
}
|
Create a responses helper for this API.
@return Responses
|
response
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function client($clientHostOrOptions = [], array $options = [])
{
if (is_array($clientHostOrOptions)) {
$options = $clientHostOrOptions;
$options['base_uri'] = isset($options['base_uri']) ?
$options['base_uri'] : $this->url->getBaseUri();
}
if (is_string($clientHostOrOptions)) {
$options = array_replace($options, [
'base_uri' => $this->url->withHost($clientHostOrOptions)->getBaseUri(),
]);
}
$client = ($clientHostOrOptions instanceof Client) ? $clientHostOrOptions : new Client($options);
return $this->factory->createClient($client, $this->getContainer(), $this->encoder());
}
|
@param Client|string|array $clientHostOrOptions
Guzzle client, string host or array of Guzzle options
@param array $options
Guzzle options, only used if first argument is a string host name.
@return ClientInterface
|
client
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function register(AbstractProvider $provider)
{
$this->resolver->attach($provider->getResolver());
}
|
Register a resource provider with this API.
@param AbstractProvider $provider
@return void
|
register
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Api.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Api.php
|
Apache-2.0
|
public function dbConnection(): ?string
{
return Arr::get($this->config, 'controllers.connection');
}
|
Get the database connection for controller transactions.
@return string|null
@deprecated
|
dbConnection
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Config.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Config.php
|
Apache-2.0
|
public function dbTransactions(): bool
{
return Arr::get($this->config, 'controllers.transactions', true);
}
|
Should database transactions be used by controllers?
@return bool
|
dbTransactions
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Config.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Config.php
|
Apache-2.0
|
public function decoding(): array
{
return $this->config['decoding'];
}
|
Get the decoding media types configuration.
@return array
|
decoding
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Config.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Config.php
|
Apache-2.0
|
public function encoding(): array
{
return $this->config['encoding'] ?? [];
}
|
Get the encoding media types configuration.
@return array
|
encoding
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Config.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Config.php
|
Apache-2.0
|
public function jobs(): array
{
return $this->config['jobs'] ?? [];
}
|
Get the asynchronous job configuration.
@return array
|
jobs
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Config.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Config.php
|
Apache-2.0
|
public function modelNamespace(): ?string
{
return $this->config['model-namespace'] ?? null;
}
|
Get the default namespace for the application's models.
@return string|null
|
modelNamespace
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Config.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Config.php
|
Apache-2.0
|
public function supportedExt(): ?string
{
return $this->config['supported-ext'] ?? null;
}
|
Get the supported extensions.
@return string|null
@deprecated
|
supportedExt
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Config.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Config.php
|
Apache-2.0
|
public function useEloquent(): bool
{
return $this->config['use-eloquent'] ?? true;
}
|
Are the application's models predominantly Eloquent models?
@return bool
|
useEloquent
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Config.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Config.php
|
Apache-2.0
|
public function __construct(string $resource, string $model)
{
if (!class_exists($model)) {
throw new \InvalidArgumentException("Expecting {$model} to be a valid class name.");
}
$this->resource = $resource;
$this->model = $model;
}
|
Jobs constructor.
@param string $resource
@param string $model
|
__construct
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Jobs.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Jobs.php
|
Apache-2.0
|
public function __construct(FactoryInterface $factory, UrlGenerator $urls, IlluminateUrlGenerator $generator)
{
$this->factory = $factory;
$this->urls = $urls;
$this->generator = $generator;
}
|
LinkGenerator constructor.
@param FactoryInterface $factory
@param UrlGenerator $urls
@param IlluminateUrlGenerator $generator
|
__construct
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function current($meta = null, array $queryParams = [])
{
$url = $this->generator->current();
if ($queryParams) {
$url .= '?' . http_build_query($queryParams);
}
return $this->createLink($url, $meta, true);
}
|
Get a link to the current path, adding in supplied query params.
@param array|object|null $meta
@param array $queryParams
@return LinkInterface
|
current
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function index($resourceType, $meta = null, array $queryParams = [])
{
return $this->createLink(
$this->urls->index($resourceType, $queryParams),
$meta,
true
);
}
|
Get a link to the index of a resource type.
@param $resourceType
@param array|object|null $meta
@param array $queryParams
@return LinkInterface
|
index
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function create($resourceType, $meta = null, array $queryParams = [])
{
return $this->createLink(
$this->urls->create($resourceType, $queryParams),
$meta,
true
);
}
|
Get a link to create a resource object.
@param $resourceType
@param array|object|null $meta
@param array $queryParams
@return LinkInterface
|
create
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function read($resourceType, $id, $meta = null, array $queryParams = [])
{
return $this->createLink(
$this->urls->read($resourceType, $id, $queryParams),
$meta,
true
);
}
|
Get a link to read a resource object.
@param $resourceType
@param $id
@param array|object|null $meta
@param array $queryParams
@return LinkInterface
|
read
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function update($resourceType, $id, $meta = null, array $queryParams = [])
{
return $this->createLink(
$this->urls->update($resourceType, $id, $queryParams),
$meta,
true
);
}
|
Get a link to update a resource object.
@param $resourceType
@param $id
@param array|object|null $meta
@param array $queryParams
@return LinkInterface
|
update
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function delete($resourceType, $id, $meta = null, array $queryParams = [])
{
return $this->createLink(
$this->urls->delete($resourceType, $id, $queryParams),
$meta,
true
);
}
|
Get a link to delete a resource object.
@param $resourceType
@param $id
@param array|object|null $meta
@param array $queryParams
@return LinkInterface
|
delete
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function relatedResource($resourceType, $id, $relationshipKey, $meta = null, array $queryParams = [])
{
return $this->createLink(
$this->urls->relatedResource($resourceType, $id, $relationshipKey, $queryParams),
$meta,
true
);
}
|
Get a link to a resource object's related resource.
@param $resourceType
@param $id
@param $relationshipKey
@param array|object|null $meta
@param array $queryParams
@return LinkInterface
|
relatedResource
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function readRelationship($resourceType, $id, $relationshipKey, $meta = null, array $queryParams = [])
{
return $this->createLink(
$this->urls->readRelationship($resourceType, $id, $relationshipKey, $queryParams),
$meta,
true
);
}
|
Get a link to read a resource object's relationship.
@param $resourceType
@param $id
@param $relationshipKey
@param array|object|null $meta
@param array $queryParams
@return LinkInterface
|
readRelationship
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function replaceRelationship($resourceType, $id, $relationshipKey, $meta = null, array $queryParams = [])
{
return $this->createLink(
$this->urls->replaceRelationship($resourceType, $id, $relationshipKey, $queryParams),
$meta,
true
);
}
|
Get a link to replace a resource object's relationship.
@param $resourceType
@param $id
@param $relationshipKey
@param array|object|null $meta
@param array $queryParams
@return LinkInterface
|
replaceRelationship
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function addRelationship($resourceType, $id, $relationshipKey, $meta = null, array $queryParams = [])
{
return $this->createLink(
$this->urls->addRelationship($resourceType, $id, $relationshipKey, $queryParams),
$meta,
true
);
}
|
Get a link to add to a resource object's relationship.
@param $resourceType
@param $id
@param $relationshipKey
@param array|object|null $meta
@param array $queryParams
@return LinkInterface
|
addRelationship
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function removeRelationship($resourceType, $id, $relationshipKey, $meta = null, array $queryParams = [])
{
return $this->createLink(
$this->urls->removeRelationship($resourceType, $id, $relationshipKey, $queryParams),
$meta,
true
);
}
|
Get a link to remove from a resource object's relationship.
@param $resourceType
@param $id
@param $relationshipKey
@param array|object|null $meta
@param array $queryParams
@return LinkInterface
|
removeRelationship
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
private function createLink(string $subHref, $meta = null, bool $treatAsHref = false): LinkInterface
{
return $this->factory->createLink(
false === $treatAsHref,
$subHref,
!is_null($meta),
$meta,
);
}
|
Create a link.
This method uses the old method signature for creating a link via the Neomerx factory, and converts
it to a call to the new factory method signature.
@param string $subHref
@param array|object|null $meta
@param bool $treatAsHref
@return LinkInterface
|
createLink
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/LinkGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/LinkGenerator.php
|
Apache-2.0
|
public function __construct(Factory $factory, ConfigRepository $config)
{
$this->factory = $factory;
$this->config = $config;
}
|
Repository constructor.
@param Factory $factory
@param ConfigRepository $config
|
__construct
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Repository.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Repository.php
|
Apache-2.0
|
public function createApi(string $apiName, ?string $host = null, array $parameters = [])
{
$config = $this->configFor($apiName);
$config = $this->normalize($config, $host);
$url = Url::fromArray($config->url())->replace($parameters);
$resolver = new AggregateResolver($this->factory->createResolver($apiName, $config->all()));
$api = new Api(
$this->factory,
$resolver,
$apiName,
$url,
$config
);
/** Attach resource providers to the API. */
$api->providers()->registerAll($api);
return $api;
}
|
Create an API instance.
@param string $apiName
@param string|null $host
@param array $parameters
route parameters, if needed.
@return Api
|
createApi
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Repository.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Repository.php
|
Apache-2.0
|
private function normalize(array $config, $host = null): Config
{
$config = array_replace([
'namespace' => null,
'by-resource' => true,
], $config);
if (!$config['namespace']) {
$config['namespace'] = rtrim(app()->getNamespace(), '\\') . '\\JsonApi';
}
$config['resources'] = $this->normalizeResources($config['resources'] ?? [], $config);
$config['url'] = $this->normalizeUrl($config['url'] ?? [], $host);
return new Config($config);
}
|
@param array $config
@param string|null $host
@return Config
|
normalize
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Repository.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Repository.php
|
Apache-2.0
|
private function configKey($apiName, $path = null)
{
$key = "json-api-$apiName";
return $path ? "$key.$path" : $key;
}
|
@param string $apiName
@param string|null $path
@return string
|
configKey
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Repository.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Repository.php
|
Apache-2.0
|
private function normalizeUrl(array $url, $host = null)
{
$prependHost = false !== Arr::get($url, 'host');
if ($host) {
$url['host'] = $host;
} elseif (!isset($url['host'])) {
$url['host'] = $this->config->get('app.url');
}
return [
'host' => $prependHost ? (string) $url['host'] : '',
'namespace' => (string) Arr::get($url, 'namespace'),
'name' => (string) Arr::get($url, 'name'),
];
}
|
@param array $url
@param string|null $host
@return array
|
normalizeUrl
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Repository.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Repository.php
|
Apache-2.0
|
private function normalizeResources(array $resources, array $config)
{
$jobs = isset($config['jobs']) ? Jobs::fromArray($config['jobs']) : null;
if ($jobs && !isset($resources[$jobs->getResource()])) {
$resources[$jobs->getResource()] = $jobs->getModel();
}
return $resources;
}
|
@param array $resources
@param array $config
@return array
|
normalizeResources
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Repository.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Repository.php
|
Apache-2.0
|
public function __construct(Factory $factory, array $providers)
{
$this->factory = $factory;
$this->providers = $providers;
}
|
ResourceProviders constructor.
@param Factory $factory
@param string[] $providers
|
__construct
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/ResourceProviders.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/ResourceProviders.php
|
Apache-2.0
|
public static function fromArray(array $url): self
{
return new self(
isset($url['host']) ? $url['host'] : '',
isset($url['namespace']) ? $url['namespace'] : '',
isset($url['name']) ? $url['name'] : ''
);
}
|
Create a URL from an array.
@param array $url
@return Url
|
fromArray
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Url.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Url.php
|
Apache-2.0
|
public function __construct(string $host, string $namespace, string $name)
{
$this->host = rtrim($host, '/');
$this->namespace = $namespace ? '/' . ltrim($namespace, '/') : '';
$this->name = $name;
}
|
Url constructor.
@param string $host
@param string $namespace
@param string $name
|
__construct
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Url.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Url.php
|
Apache-2.0
|
public function replace(iterable $parameters): self
{
if (!Str::contains($this->namespace, '{')) {
return $this;
}
$copy = clone $this;
foreach ($parameters as $key => $value) {
$routeParamValue = $value;
if ($value instanceof UrlRoutable) {
$routeParamValue = $value->getRouteKey();
}
$copy->namespace = \str_replace('{' . $key . '}', $routeParamValue, $copy->namespace);
}
return $copy;
}
|
Replace route parameters in the URL namespace.
@param iterable $parameters
@return Url
|
replace
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Url.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Url.php
|
Apache-2.0
|
public function getBaseUri(): string
{
return $this->toString() . '/';
}
|
Get the base URI for a Guzzle client.
@return string
|
getBaseUri
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Url.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Url.php
|
Apache-2.0
|
public function getResourceTypeUrl(string $type, array $params = []): string
{
return $this->url([$type], $params);
}
|
Get the URL for the resource type.
@param string $type
@param array $params
@return string
|
getResourceTypeUrl
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Url.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Url.php
|
Apache-2.0
|
public function getResourceUrl(string $type, $id, array $params = []): string
{
return $this->url([$type, $id], $params);
}
|
Get the URL for the specified resource.
@param string $type
@param mixed $id
@param array $params
@return string
|
getResourceUrl
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Url.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Url.php
|
Apache-2.0
|
public function getRelatedUrl(string $type, $id, string $field, array $params = []): string
{
return $this->url([$type, $id, $field], $params);
}
|
Get the URI for a related resource.
@param string $type
@param mixed $id
@param string $field
@param array $params
@return string
|
getRelatedUrl
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Url.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Url.php
|
Apache-2.0
|
public function getRelationshipUri(string $type, $id, string $field, array $params = []): string
{
return $this->url([$type, $id, 'relationships', $field], $params);
}
|
Get the URI for the resource's relationship.
@param string $type
@param mixed $id
@param string $field
@param array $params
@return string
|
getRelationshipUri
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Url.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Url.php
|
Apache-2.0
|
private function url(array $extra, array $params = []): string
{
$url = collect([$this->toString()])->merge($extra)->map(function ($value) {
return $value instanceof UrlRoutable ? $value->getRouteKey() : (string) $value;
})->implode('/');
return $params ? $url . '?' . http_build_query($params) : $url;
}
|
@param array $extra
@param array $params
@return string
|
url
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/Url.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/Url.php
|
Apache-2.0
|
public function __construct(IlluminateUrlGenerator $generator, Url $url)
{
$this->generator = $generator;
$this->url = $url;
}
|
UrlGenerator constructor.
@param IlluminateUrlGenerator $generator
@param Url $url
|
__construct
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
public function index($resourceType, array $queryParams = [])
{
return $this->route(RouteName::index($resourceType), $queryParams);
}
|
Get a link to the index of a resource type.
@param $resourceType
@param array $queryParams
@return string
|
index
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
public function create($resourceType, array $queryParams = [])
{
return $this->route(RouteName::create($resourceType), $queryParams);
}
|
Get a link to create a resource object.
@param $resourceType
@param array $queryParams
@return string
|
create
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
public function read($resourceType, $id, array $queryParams = [])
{
return $this->resource(RouteName::read($resourceType), $id, $queryParams);
}
|
Get a link to read a resource object.
@param $resourceType
@param $id
@param array $queryParams
@return string
|
read
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
public function update($resourceType, $id, array $queryParams = [])
{
return $this->resource(RouteName::update($resourceType), $id, $queryParams);
}
|
Get a link to update a resource object.
@param $resourceType
@param $id
@param array $queryParams
@return string
|
update
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
public function delete($resourceType, $id, array $queryParams = [])
{
return $this->resource(RouteName::delete($resourceType), $id, $queryParams);
}
|
Get a link to delete a resource object.
@param $resourceType
@param $id
@param array $queryParams
@return string
|
delete
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
public function relatedResource($resourceType, $id, $relationshipKey, array $queryParams = [])
{
return $this->resource(RouteName::related($resourceType, $relationshipKey), $id, $queryParams);
}
|
Get a link to a resource object's related resource.
@param $resourceType
@param $id
@param $relationshipKey
@param array $queryParams
@return string
|
relatedResource
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
public function readRelationship($resourceType, $id, $relationshipKey, array $queryParams = [])
{
$name = RouteName::readRelationship($resourceType, $relationshipKey);
return $this->resource($name, $id, $queryParams);
}
|
Get a link to read a resource object's relationship.
@param $resourceType
@param $id
@param $relationshipKey
@param array $queryParams
@return string
|
readRelationship
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
public function replaceRelationship($resourceType, $id, $relationshipKey, array $queryParams = [])
{
$name = RouteName::replaceRelationship($resourceType, $relationshipKey);
return $this->resource($name, $id, $queryParams);
}
|
Get a link to replace a resource object's relationship.
@param $resourceType
@param $id
@param $relationshipKey
@param array $queryParams
@return string
|
replaceRelationship
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
public function addRelationship($resourceType, $id, $relationshipKey, array $queryParams = [])
{
$name = RouteName::addRelationship($resourceType, $relationshipKey);
return $this->resource($name, $id, $queryParams);
}
|
Get a link to add to a resource object's relationship.
@param $resourceType
@param $id
@param $relationshipKey
@param array $queryParams
@return string
|
addRelationship
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
public function removeRelationship($resourceType, $id, $relationshipKey, array $queryParams = [])
{
$name = RouteName::removeRelationship($resourceType, $relationshipKey);
return $this->resource($name, $id, $queryParams);
}
|
Get a link to remove from a resource object's relationship.
@param $resourceType
@param $id
@param $relationshipKey
@param array $queryParams
@return string
|
removeRelationship
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
private function route($name, $parameters = [])
{
$name = $this->url->getName() . $name;
return $this->generator->route($name, $parameters, true);
}
|
@param $name
@param array $parameters
@return string
|
route
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
private function resource($name, $id, $parameters = [])
{
$parameters[ResourceRegistrar::PARAM_RESOURCE_ID] = $id;
return $this->route($name, $parameters);
}
|
@param $name
@param $id
@param array $parameters
@return string
|
resource
|
php
|
cloudcreativity/laravel-json-api
|
src/Api/UrlGenerator.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Api/UrlGenerator.php
|
Apache-2.0
|
protected function can($ability, ...$arguments)
{
$this->authenticate();
$this->authorize($ability, $arguments);
}
|
@param $ability
@param mixed ...$arguments
@throws AuthenticationException
@throws AuthorizationException
|
can
|
php
|
cloudcreativity/laravel-json-api
|
src/Auth/AuthorizesRequests.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Auth/AuthorizesRequests.php
|
Apache-2.0
|
protected function authenticate()
{
if (empty($this->guards) && Auth::check()) {
return;
}
foreach ($this->guards as $guard) {
if (Auth::guard($guard)->check()) {
Auth::shouldUse($guard);
return;
}
}
throw new AuthenticationException('Unauthenticated.', $this->guards);
}
|
Determine if the user is logged in.
@return void
@throws AuthenticationException
|
authenticate
|
php
|
cloudcreativity/laravel-json-api
|
src/Auth/AuthorizesRequests.php
|
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Auth/AuthorizesRequests.php
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.