protected function createRouteName(ApiEndpoint $endpoint) { return serialize(['collection' => $this->getIdentifier(), 'endpoint' => $endpoint->getIdentifier()]); }
public function initialize() { $this->name('User')->model(User::class)->expectsJsonData()->transformer(UserTransformer::class)->handler(UserController::class)->itemKey('user')->collectionKey('users')->deny(AclRoles::UNAUTHORIZED, AclRoles::USER)->endpoint(ApiEndpoint::all()->allow(AclRoles::USER)->description('Returns all registered users'))->endpoint(ApiEndpoint::get('/me', 'me')->allow(AclRoles::USER)->description('Returns the currently logged in user'))->endpoint(ApiEndpoint::post('/authenticate', 'authenticate')->allow(AclRoles::UNAUTHORIZED)->deny(AclRoles::AUTHORIZED)->description('Authenticates user credentials provided in the authorization header and returns an access token')->exampleResponse(['token' => 'co126bbm40wqp41i3bo7pj1gfsvt9lp6', 'expires' => 1451139067])); }
protected function initialize() { $this->name('Export')->handler(ExportController::class)->endpoint(ApiEndpoint::get('/documentation.json', 'documentation'))->endpoint(ApiEndpoint::get('/postman.json', 'postman')); }
public function initialize() { $this->name('Photo')->model(Photo::class)->expectsJsonData()->transformer(PhotoTransformer::class)->itemKey('photo')->collectionKey('photos')->deny(AclRoles::UNAUTHORIZED)->handler(CrudResourceController::class)->endpoint(ApiEndpoint::all())->endpoint(ApiEndpoint::create())->endpoint(ApiEndpoint::find())->endpoint(ApiEndpoint::update())->endpoint(ApiEndpoint::remove()); }
/** * Returns resource with default values & all, find, create, update and delete endpoints pre-configured * * @param string $prefix Prefix for the resource (e.g. /user) * @param string $name Name for the resource (e.g. users) (optional) * * @return static */ public static function crud($prefix, $name = null) { return self::factory($prefix, $name)->endpoint(ApiEndpoint::all())->endpoint(ApiEndpoint::find())->endpoint(ApiEndpoint::create())->endpoint(ApiEndpoint::update())->endpoint(ApiEndpoint::remove()); }