for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\LaravelEndpointResources;
use Illuminate\Support\Arr;
use Spatie\LaravelEndpointResources\EndpointTypes\ControllerEndpointType;
trait HasEndpoints
{
/** @var bool */
protected $includeGlobalEndpoints = false;
public function endpoints(string $controller = null, $parameters = null): EndpointResource
$endPointResource = new EndpointResource($this->resource, $this->includeGlobalEndpoints);
resource
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
if ($controller !== null) {
$endPointResource->addController($controller, Arr::wrap($parameters));
}
return $endPointResource;
public static function globalEndpoints(string $controller = null, $parameters = null): GlobalEndpointResource
$globalEndpointResource = new GlobalEndpointResource();
$globalEndpointResource->addController($controller, Arr::wrap($parameters));
return $globalEndpointResource;
public static function meta()
return [];
public function includeGlobalEndpoints()
$this->includeGlobalEndpoints = true;
return $this;
public static function collection($resource)
return parent::collection($resource)->additional([
'meta' => self::meta(),
]);
public static function make(...$parameters)
return parent::make(...$parameters)->includeGlobalEndpoints();
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: