Skip to content

Instantly share code, notes, and snippets.

@mucyomiller
Last active June 14, 2016 13:42
Show Gist options
  • Save mucyomiller/576a9b81e7a1d07c23485a6289003f40 to your computer and use it in GitHub Desktop.
Save mucyomiller/576a9b81e7a1d07c23485a6289003f40 to your computer and use it in GitHub Desktop.
APP_ENV=local
APP_DEBUG=true
APP_KEY=my base64 app key
APP_URL =myurlhere
DB_HOST=localhost
DB_DATABASE=mydbnamehere
DB_USERNAME=myusername
DB_PASSWORD=mypassword
JWT_BLACKLIST_ENABLED=false
CACHE_DRIVER=array
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mysmtp
MAIL_PORT=myport
MAIL_USERNAME=myusername
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=ssl
API_PREFIX = 'api'
API_DOMAIN ='mydomainapi'
API_DEBUG =true
<?php
return [
/*
|--------------------------------------------------------------------------
| Standards Tree
|--------------------------------------------------------------------------
|
| Versioning an API with Dingo revolves around content negotiation and
| custom MIME types. A custom type will belong to one of three
| standards trees, the Vendor tree (vnd), the Personal tree
| (prs), and the Unregistered tree (x).
|
| By default the Unregistered tree (x) is used, however, should you wish
| to you can register your type with the IANA. For more details:
| https://tools.ietf.org/html/rfc6838
|
*/
'standardsTree' => env('API_STANDARDS_TREE', 'vnd'),
/*
|--------------------------------------------------------------------------
| API Subtype
|--------------------------------------------------------------------------
|
| Your subtype will follow the standards tree you use when used in the
| "Accept" header to negotiate the content type and version.
|
| For example: Accept: application/x.SUBTYPE.v1+json
|
*/
'subtype' => env('API_SUBTYPE', 'tiba'),
/*
|--------------------------------------------------------------------------
| Default API Version
|--------------------------------------------------------------------------
|
| This is the default version when strict mode is disabled and your API
| is accessed via a web browser. It's also used as the default version
| when generating your APIs documentation.
|
*/
'version' => env('API_VERSION', 'v1'),
/*
|--------------------------------------------------------------------------
| Default API Prefix
|--------------------------------------------------------------------------
|
| A default prefix to use for your API routes so you don't have to
| specify it for each group.
|
*/
'prefix' => env('API_PREFIX', null),
/*
|--------------------------------------------------------------------------
| Default API Domain
|--------------------------------------------------------------------------
|
| A default domain to use for your API routes so you don't have to
| specify it for each group.
|
*/
'domain' => env('API_DOMAIN', null),
/*
|--------------------------------------------------------------------------
| Name
|--------------------------------------------------------------------------
|
| When documenting your API using the API Blueprint syntax you can
| configure a default name to avoid having to manually specify
| one when using the command.
|
*/
'name' => env('API_NAME', 'tiba api'),
/*
|--------------------------------------------------------------------------
| Conditional Requests
|--------------------------------------------------------------------------
|
| Globally enable conditional requests so that an ETag header is added to
| any successful response. Subsequent requests will perform a check and
| will return a 304 Not Modified. This can also be enabled or disabled
| on certain groups or routes.
|
*/
'conditionalRequest' => env('API_CONDITIONAL_REQUEST', true),
/*
|--------------------------------------------------------------------------
| Strict Mode
|--------------------------------------------------------------------------
|
| Enabling strict mode will require clients to send a valid Accept header
| with every request. This also voids the default API version, meaning
| your API will not be browsable via a web browser.
|
*/
'strict' => env('API_STRICT', false),
/*
|--------------------------------------------------------------------------
| Debug Mode
|--------------------------------------------------------------------------
|
| Enabling debug mode will result in error responses caused by thrown
| exceptions to have a "debug" key that will be populated with
| more detailed information on the exception.
|
*/
'debug' => env('API_DEBUG', true),
/*
|--------------------------------------------------------------------------
| Generic Error Format
|--------------------------------------------------------------------------
|
| When some HTTP exceptions are not caught and dealt with the API will
| generate a generic error response in the format provided. Any
| keys that aren't replaced with corresponding values will be
| removed from the final response.
|
*/
'errorFormat' => [
'message' => ':message',
'errors' => ':errors',
'code' => ':code',
'status_code' => ':status_code',
'debug' => ':debug',
],
/*
|--------------------------------------------------------------------------
| API Middleware
|--------------------------------------------------------------------------
|
| Middleware that will be applied globally to all API requests.
|
*/
'middleware' => [
],
/*
|--------------------------------------------------------------------------
| Authentication Providers
|--------------------------------------------------------------------------
|
| The authentication providers that should be used when attempting to
| authenticate an incoming API request.
|
*/
'auth' => [
],
/*
|--------------------------------------------------------------------------
| Throttling / Rate Limiting
|--------------------------------------------------------------------------
|
| Consumers of your API can be limited to the amount of requests they can
| make. You can create your own throttles or simply change the default
| throttles.
|
*/
'throttling' => [
],
/*
|--------------------------------------------------------------------------
| Response Transformer
|--------------------------------------------------------------------------
|
| Responses can be transformed so that they are easier to format. By
| default a Fractal transformer will be used to transform any
| responses prior to formatting. You can easily replace
| this with your own transformer.
|
*/
'transformer' => env('API_TRANSFORMER', Dingo\Api\Transformer\Adapter\Fractal::class),
/*
|--------------------------------------------------------------------------
| Response Formats
|--------------------------------------------------------------------------
|
| Responses can be returned in multiple formats by registering different
| response formatters. You can also customize an existing response
| formatter.
|
*/
'defaultFormat' => env('API_DEFAULT_FORMAT', 'json'),
'formats' => [
'json' => Dingo\Api\Http\Response\Format\Json::class,
],
];
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => env('APP_LOG', 'single'),
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Dingo\Api\Provider\LaravelServiceProvider::class,
Zizaco\Entrust\EntrustServiceProvider::class,
LucaDegasperi\OAuth2Server\Storage\FluentStorageServiceProvider::class,
LucaDegasperi\OAuth2Server\OAuth2ServerServiceProvider::class,
Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class,
App\Providers\OAuthServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
'App' => Illuminate\Support\Facades\App::class,
'Artisan' => Illuminate\Support\Facades\Artisan::class,
'Auth' => Illuminate\Support\Facades\Auth::class,
'Blade' => Illuminate\Support\Facades\Blade::class,
'Cache' => Illuminate\Support\Facades\Cache::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
'Schema' => Illuminate\Support\Facades\Schema::class,
'Session' => Illuminate\Support\Facades\Session::class,
'Storage' => Illuminate\Support\Facades\Storage::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Entrust' => Zizaco\Entrust\EntrustFacade::class,
'Authorizer' => LucaDegasperi\OAuth2Server\Facades\Authorizer::class,
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,
],
];
[2016-06-14 13:04:23] local.ERROR: ErrorException: array_merge(): Argument #1 is not an array in /var/www/html/TibaAPI/vendor/dingo/api/src/Routing/R$
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'array_merge(): ...', '/var/www/html/T...', 203, Array)
#1 /var/www/html/TibaAPI/vendor/dingo/api/src/Routing/Route.php(203): array_merge('web', Array)
#2 /var/www/html/TibaAPI/vendor/dingo/api/src/Routing/Route.php(167): Dingo\Api\Routing\Route->mergeControllerProperties()
#3 /var/www/html/TibaAPI/vendor/dingo/api/src/Routing/Route.php(144): Dingo\Api\Routing\Route->setupRouteProperties(Object(Dingo\Api\Http\Request), O$
#4 /var/www/html/TibaAPI/vendor/dingo/api/src/Routing/Router.php(713): Dingo\Api\Routing\Route->__construct(Object(Dingo\Api\Routing\Adapter\Laravel)$
#5 /var/www/html/TibaAPI/vendor/dingo/api/src/Routing/Router.php(691): Dingo\Api\Routing\Router->createRoute(Object(Illuminate\Routing\Route))
#6 /var/www/html/TibaAPI/vendor/dingo/api/src/Routing/Router.php(653): Dingo\Api\Routing\Router->getCurrentRoute()
#7 /var/www/html/TibaAPI/vendor/dingo/api/src/Routing/Router.php(623): Dingo\Api\Routing\Router->requestIsConditional()
#8 /var/www/html/TibaAPI/vendor/dingo/api/src/Routing/Router.php(589): Dingo\Api\Routing\Router->prepareResponse(Object(Dingo\Api\Http\Response), Obj$
#9 /var/www/html/TibaAPI/vendor/dingo/api/src/Http/Middleware/Request.php(123): Dingo\Api\Routing\Router->dispatch(Object(Dingo\Api\Http\Request))
#10 [internal function]: Dingo\Api\Http\Middleware\Request->Dingo\Api\Http\Middleware\{closure}(Object(Dingo\Api\Http\Request))
#11 /var/www/html/TibaAPI/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(150): call_user_func(Object(Closure), Object(Dingo\Api\Http\R$
#12 /var/www/html/TibaAPI/vendor/lucadegasperi/oauth2-server-laravel/src/Middleware/OAuthExceptionHandlerMiddleware.php(36): Illuminate\Pipeline\Pipe$
#13 [internal function]: LucaDegasperi\OAuth2Server\Middleware\OAuthExceptionHandlerMiddleware->handle(Object(Dingo\Api\Http\Request), Object(Closure$
#14 /var/www/html/TibaAPI/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#15 /var/www/html/TibaAPI/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Pipeline\Pip$
#16 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Dingo\Api\Http\Request), Object(Closure))
#17 /var/www/html/TibaAPI/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#18 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Dingo\Api\Http\Request))
#19 /var/www/html/TibaAPI/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Dingo\Api\Http\R$
#20 /var/www/html/TibaAPI/vendor/dingo/api/src/Http/Middleware/Request.php(124): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#21 /var/www/html/TibaAPI/vendor/dingo/api/src/Http/Middleware/Request.php(100): Dingo\Api\Http\Middleware\Request->sendRequestThroughRouter(Object(D$
#22 [internal function]: Dingo\Api\Http\Middleware\Request->handle(Object(Dingo\Api\Http\Request), Object(Closure))
#23 /var/www/html/TibaAPI/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(136): call_user_func_array(Array, Array)
#24 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#25 /var/www/html/TibaAPI/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Re$
#26 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#27 /var/www/html/TibaAPI/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Illuminate\Http\$
#28 /var/www/html/TibaAPI/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(132): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#29 /var/www/html/TibaAPI/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(99): Illuminate\Foundation\Http\Kernel->sendRequestThrou$
#30 /var/www/html/TibaAPI/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#31 {main}
<?php
namespace Dingo\Api\Routing;
use Closure;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Container\Container;
use Dingo\Api\Contract\Routing\Adapter;
class Route
{
/**
* Routing adapter instance.
*
* @var \Dingo\Api\Contract\Routing\Adapter
*/
protected $adapter;
/**
* Container instance.
*
* @var \Illuminate\Container\Container
*/
protected $container;
protected $route;
/**
* Route URI.
*
* @var string
*/
protected $uri;
/**
* Array of HTTP methods.
*
* @var array
*/
protected $methods;
/**
* Array of route action attributes.
*
* @var array
*/
protected $action;
/**
* Array of versions this route will respond to.
*
* @var array
*/
protected $versions;
/**
* Array of scopes for OAuth 2.0 authentication.
*
* @var array
*/
protected $scopes;
/**
* Array of authentication providers.
*
* @var array
*/
protected $authenticationProviders;
/**
* The rate limit for this route.
*
* @var int
*/
protected $rateLimit;
/**
* The expiration time for any rate limit set on this rate.
*
* @var int
*/
protected $rateExpiration;
/**
* The throttle used by the route, takes precedence over rate limits.
*
* @return string|\Dingo\Api\Contract\Http\RateLimit\Throttle
*/
protected $throttle;
/**
* Controller instance.
*
* @var object
*/
protected $controller;
/**
* Controller method name.
*
* @var string
*/
protected $controllerMethod;
/**
* Controller class name.
*
* @var string
*/
protected $controllerClass;
/**
* Indicates if the request is conditional.
*
* @var bool
*/
protected $conditionalRequest = true;
/**
* Middleware applied to route.
*
* @var array
*/
protected $middleware;
/**
* Create a new route instance.
*
* @param \Dingo\Api\Contract\Routing\Adapter $adapter
* @param \Illuminate\Container\Container $container
* @param \Illuminate\Http\Request $request
* @param array|\Illuminate\Routing\Route $route
*
* @return void
*/
public function __construct(Adapter $adapter, Container $container, Request $request, $route)
{
$this->adapter = $adapter;
$this->container = $container;
$this->route = $route;
$this->setupRouteProperties($request, $route);
}
/**
* Setup the route properties.
*
* @return void
*/
protected function setupRouteProperties(Request $request, $route)
{
list($this->uri, $this->methods, $this->action) = $this->adapter->getRouteProperties($route, $request);
$this->versions = Arr::pull($this->action, 'version');
$this->conditionalRequest = Arr::pull($this->action, 'conditionalRequest', true);
$this->middleware = Arr::pull($this->action, 'middleware', []);
$this->throttle = Arr::pull($this->action, 'throttle');
$this->scopes = Arr::pull($this->action, 'scopes', []);
$this->authenticationProviders = Arr::pull($this->action, 'providers', []);
$this->rateLimit = Arr::pull($this->action, 'limit', 0);
$this->rateExpiration = Arr::pull($this->action, 'expires', 0);
// Now that the default route properties have been set we'll go ahead and merge
// any controller properties to fully configure the route.
$this->mergeControllerProperties();
// If we have a string based throttle then we'll new up an instance of the
// throttle through the container.
if (is_string($this->throttle)) {
$this->throttle = $this->container->make($this->throttle);
}
}
/**
* Merge the controller properties onto the route properties.
*
* @return void
*/
protected function mergeControllerProperties()
{
if (isset($this->action['uses']) && is_string($this->action['uses']) && Str::contains($this->action['uses'], '@')) {
$this->action['controller'] = $this->action['uses'];
$this->makeControllerInstance();
}
if (! $this->controllerUsesHelpersTrait()) {
return;
}
$controller = $this->getControllerInstance();
$controllerMiddleware = [];
if (method_exists($controller, 'getMiddleware')) {
$controllerMiddleware = $controller->getMiddleware();
} elseif (method_exists($controller, 'getMiddlewareForMethod')) {
$controllerMiddleware = $controller->getMiddlewareForMethod($this->controllerMethod);
}
$this->middleware = array_merge($this->middleware, $controllerMiddleware);
if ($property = $this->findControllerPropertyOptions('throttles')) {
$this->throttle = $property['class'];
}
if ($property = $this->findControllerPropertyOptions('scopes')) {
$this->scopes = array_merge($this->scopes, $property['scopes']);
}
if ($property = $this->findControllerPropertyOptions('authenticationProviders')) {
$this->authenticationProviders = array_merge($this->authenticationProviders, $property['providers']);
}
if ($property = $this->findControllerPropertyOptions('rateLimit')) {
$this->rateLimit = $property['limit'];
$this->rateExpiration = $property['expires'];
}
}
/**
* Find the controller options and whether or not it will apply to this routes controller method.
*
* @param string $option
* @param \Closure $callback
*
* @return void
*/
protected function findControllerPropertyOptions($name)
{
$properties = [];
foreach ($this->getControllerInstance()->{'get'.ucfirst($name)}() as $property) {
if (isset($property['options']) && ! $this->optionsApplyToControllerMethod($property['options'])) {
continue;
}
unset($property['options']);
$properties = array_merge_recursive($properties, $property);
}
return $properties;
}
/**
* Determine if a controller method is in an array of options.
*
* @param array $options
*
* @return bool
*/
protected function optionsApplyToControllerMethod(array $options)
{
if (empty($options)) {
return true;
} elseif (isset($options['only']) && in_array($this->controllerMethod, $this->explodeOnPipes($options['only']))) {
return true;
} elseif (isset($options['except'])) {
return ! in_array($this->controllerMethod, $this->explodeOnPipes($options['except']));
} elseif (in_array($this->controllerMethod, $this->explodeOnPipes($options))) {
return true;
}
return false;
}
/**
* Explode a value on a pipe delimiter.
*
* @param string|array $value
*
* @return array
*/
protected function explodeOnPipes($value)
{
return is_string($value) ? explode('|', $value) : $value;
}
/**
* Determine if the controller instance uses the helpers trait.
*
* @return bool
*/
protected function controllerUsesHelpersTrait()
{
if (! $controller = $this->getControllerInstance()) {
return false;
}
$traits = [];
do {
$traits = array_merge(class_uses($controller, false), $traits);
} while ($controller = get_parent_class($controller));
foreach ($traits as $trait => $same) {
$traits = array_merge(class_uses($trait, false), $traits);
}
return isset($traits['Dingo\Api\Routing\Helpers']);
}
/**
* Get the routes controller instance.
*
* @return null|\Illuminate\Routing\Controller|\Laravel\Lumen\Routing\Controller
*/
public function getControllerInstance()
{
return $this->controller;
}
/**
* Make a new controller instance through the container.
*
* @return \Illuminate\Routing\Controller|\Laravel\Lumen\Routing\Controller
*/
protected function makeControllerInstance()
{
list($this->controllerClass, $this->controllerMethod) = explode('@', $this->action['uses']);
$this->container->instance($this->controllerClass, $this->controller = $this->container->make($this->controllerClass));
return $this->controller;
}
/**
* Get the middleware for this route.
*
* @return array
*/
public function middleware()
{
return $this->middleware;
}
/**
* Get the middleware for this route.
*
* @return array
*/
public function getMiddleware()
{
return $this->middleware;
}
/**
* Determine if the route is protected.
*
* @return bool
*/
public function isProtected()
{
if (isset($this->middleware['api.auth']) || in_array('api.auth', $this->middleware)) {
if ($this->controller && isset($this->middleware['api.auth'])) {
return $this->optionsApplyToControllerMethod($this->middleware['api.auth']);
}
return true;
}
return false;
}
/**
* Determine if the route has a throttle.
*
* @return bool
*/
public function hasThrottle()
{
return ! is_null($this->throttle);
}
/**
* Get the route throttle.
*
* @return string|\Dingo\Api\Http\RateLimit\Throttle\Throttle
*/
public function throttle()
{
return $this->throttle;
}
/**
* Get the route throttle.
*
* @return string|\Dingo\Api\Http\RateLimit\Throttle\Throttle
*/
public function getThrottle()
{
return $this->throttle;
}
/**
* Get the route scopes.
*
* @return array
*/
public function scopes()
{
return $this->scopes;
}
/**
* Get the route scopes.
*
* @return array
*/
public function getScopes()
{
return $this->scopes;
}
/**
* Check if route requires all scopes or any scope to be valid.
*
* @return bool
*/
public function scopeStrict()
{
return Arr::get($this->action, 'scopeStrict', false);
}
/**
* Get the route authentication providers.
*
* @return array
*/
public function authenticationProviders()
{
return $this->authenticationProviders;
}
/**
* Get the route authentication providers.
*
* @return array
*/
public function getAuthenticationProviders()
{
return $this->authenticationProviders;
}
/**
* Get the rate limit for this route.
*
* @return int
*/
public function rateLimit()
{
return $this->rateLimit;
}
/**
* Get the rate limit for this route.
*
* @return int
*/
public function getRateLimit()
{
return $this->rateLimit;
}
/**
* Get the rate limit expiration time for this route.
*
* @return int
*/
public function rateLimitExpiration()
{
return $this->rateExpiration;
}
/**
* Get the rate limit expiration time for this route.
*
* @return int
*/
public function getRateLimitExpiration()
{
return $this->rateExpiration;
}
/**
* Get the name of the route.
*
* @return string
*/
public function getName()
{
return Arr::get($this->action, 'as', null);
}
/**
* Determine if the request is conditional.
*
* @return bool
*/
public function requestIsConditional()
{
return $this->conditionalRequest === true;
}
/**
* Get the route action.
*
* @return array
*/
public function getAction()
{
return $this->action;
}
/**
* Get the action name for the route.
*
* @return string
*/
public function getActionName()
{
return Arr::get($this->action, 'controller', 'Closure');
}
/**
* Get the versions for the route.
*
* @return array
*/
public function getVersions()
{
return $this->versions;
}
/**
* Get the versions for the route.
*
* @return array
*/
public function versions()
{
return $this->getVersions();
}
/**
* Get the URI associated with the route.
*
* @return string
*/
public function getPath()
{
return $this->uri();
}
/**
* Get the URI associated with the route.
*
* @return string
*/
public function uri()
{
return $this->uri;
}
/**
* Get the HTTP verbs the route responds to.
*
* @return array
*/
public function getMethods()
{
return $this->methods();
}
/**
* Get the HTTP verbs the route responds to.
*
* @return array
*/
public function methods()
{
return $this->methods;
}
/**
* Determine if the route only responds to HTTP requests.
*
* @return bool
*/
public function httpOnly()
{
return in_array('http', $this->action, true);
}
/**
* Determine if the route only responds to HTTPS requests.
*
* @return bool
*/
public function httpsOnly()
{
return $this->secure();
}
/**
* Determine if the route only responds to HTTPS requests.
*
* @return bool
*/
public function secure()
{
return in_array('https', $this->action, true);
}
/**
* Get the domain defined for the route.
*
* @return string|null
*/
public function domain()
{
return Arr::get($this->action, 'domain');
}
/**
* Get the original route.
*
* @return array|\Illuminate\Routing\Route
*/
public function getOriginalRoute()
{
return $this->route;
}
}
<?php
use App\User;
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
// default https routes
Route::get('/', function () {
return view('welcome');
});
//frontend routes
Route::group(['prefix'=>'user'],function(){
Route::get('dashboard',['as'=>'userhome','uses'=>'UserController@index']);
Route::get('apply',['as'=>'apply','uses'=>'UserController@apply']);
});
Route::group(['prefix'=>'admin'],function(){
Route::get('dashboard',['as'=>'adminhome','uses'=>'AdminController@index']);
});
Route::get('user/activation/{token}', 'Auth\AuthController@activateUser')->name('user.activate');
//Api routes
$api =app('Dingo\Api\Routing\Router');
$api->version('v1', function($api){
$api->get('contact', 'App\Http\Controllers\Api\V1\UserController@index');
$api->post('contact/add','App\Http\Controllers\Api\V1\UserController@store');
$api->get('contact/{id}', 'App\Http\Controllers\Api\V1\UserController@show');
$api->delete('contact/{id}', 'App\Http\Controllers\Api\V1\UserController@destroy');
$api->post('authenticate','App\Http\Controllers\AuthenticateController@authenticate');
$api->get('last', 'App\Http\Controllers\Api\V1\UserController@returnLastUser');
});
//OAuth2 routes to give access and refresh token
$api->version('v1', function($api){
$api->post('oauth/access_token',function(){
return Authorizer::issueAccessToken();
});
});
Route::auth();
Route::get('/home', 'HomeController@index');
Route::get('phone','UserController@phone');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment