Call to undefined method Illuminate\Routing\Route::getUri() - php

I am trying to make rest api with dingo for laravel 5.3 . I have setup dingo on my project and created a api route like this for test .
$api->version('v1', function ($api) {
$api->get('hello',function (){
return "hello";
});
});
But when i run http://localhost:8000/api/hello
Then
{
message: "Call to undefined method Illuminate\Routing\Route::getUri()",
code: 1,
status_code: 500,
debug: {
line: 98,
file: "C:\xampp\htdocs\apiTest\vendor\dingo\api\src\Routing\Adapter\Laravel.php",
class: "Symfony\Component\Debug\Exception\FatalErrorException",
trace: [
"#0 {main}"
]
}
}
is shown .
i have searched and find this solution
Call to undefined method Illuminate\Routing\Route::get()
but when i used
use Illuminate\Support\Facades\Route;
then this problem shown
FatalErrorException in Laravel.php line 116:
Call to undefined method Illuminate\Support\Facades\Route::where()
This is the Laravel.php file
<?php
namespace Dingo\Api\Routing\Adapter;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Routing\Router;
use Illuminate\Routing\RouteCollection;
use Dingo\Api\Contract\Routing\Adapter;
use Dingo\Api\Exception\UnknownVersionException;
class Laravel implements Adapter
{
/**
* Laravel router instance.
*
* #var \Illuminate\Routing\Router
*/
protected $router;
/**
* Array of registered routes.
*
* #var array
*/
protected $routes = [];
/**
* Old routes already defined on the router.
*
* #var \Illuminate\Routing\RouteCollection
*/
protected $oldRoutes;
/**
* Create a new laravel routing adapter instance.
*
* #param \Illuminate\Routing\Router $router
*
* #return void
*/
public function __construct(Router $router)
{
$this->router = $router;
}
/**
* Dispatch a request.
*
* #param \Illuminate\Http\Request $request
* #param string $version
*
* #return mixed
*/
public function dispatch(Request $request, $version)
{
if (! isset($this->routes[$version])) {
throw new UnknownVersionException;
}
$routes = $this->mergeExistingRoutes($this->routes[$version]);
$this->router->setRoutes($routes);
return $this->router->dispatch($request);
}
/**
* Merge the existing routes with the new routes.
*
* #param \Illuminate\Routing\RouteCollection $routes
*
* #return \Illuminate\Routing\RouteCollection
*/
protected function mergeExistingRoutes(RouteCollection $routes)
{
if (! isset($this->oldRoutes)) {
$this->oldRoutes = $this->router->getRoutes();
}
foreach ($this->oldRoutes as $route) {
$routes->add($route);
}
return $routes;
}
/**
* Get the URI, methods, and action from the route.
*
* #param mixed $route
* #param \Illuminate\Http\Request $request
*
* #return array
*/
public function getRouteProperties($route, Request $request)
{
return [$route->getUri(), $route->getMethods(), $route->getAction()];
}
/**
* Add a route to the appropriate route collection.
*
* #param array $methods
* #param array $versions
* #param string $uri
* #param mixed $action
*
* #return \Illuminate\Routing\Route
*/
public function addRoute(array $methods, array $versions, $uri, $action)
{
$this->createRouteCollections($versions);
$route = new Route($methods, $uri, $action);
$route->where($action['where']);
foreach ($versions as $version) {
$this->routes[$version]->add($route);
}
return $route;
}
/**
* Create the route collections for the versions.
*
* #param array $versions
*
* #return void
*/
protected function createRouteCollections(array $versions)
{
foreach ($versions as $version) {
if (! isset($this->routes[$version])) {
$this->routes[$version] = new RouteCollection;
}
}
}
/**
* Get all routes or only for a specific version.
*
* #param string $version
*
* #return mixed
*/
public function getRoutes($version = null)
{
if (! is_null($version)) {
return $this->routes[$version];
}
return $this->routes;
}
public function getIterableRoutes($version = null)
{
return $this->getRoutes($version);
}
/**
* Set the routes on the adapter.
*
* #param array $routes
*
* #return void
*/
public function setRoutes(array $routes)
{
$this->routes = $routes;
}
/**
* Prepare a route for serialization.
*
* #param mixed $route
*
* #return mixed
*/
public function prepareRouteForSerialization($route)
{
$route->prepareForSerialization();
return $route;
}
/**
* Gather the route middlewares.
*
* #param \Illuminate\Routing\Route $route
*
* #return array
*/
public function gatherRouteMiddlewares($route)
{
return $this->router->gatherRouteMiddlewares($route);
}
}
Has there any solution ?
Thanks

Use $route->uri()
insted of $route->getUri()
create a pull request to dingo api after updating this

Related

Create group route with Closure in PHP (similar laravel)

How can i group routes by a middleware or route prefix, using Closure? Similar to laravel (without using 'use' like other answers in the community and doing with static call).
I dont know how to group all these calls inside the closure. How can i do this? Some example?
web.php (file routes):
//web.php file
Router::middleware(['auth', 'okok'])->group(function(){
Router::get('/teste', [TestController::class, 'test']);
Router::get('/teste2', [TestController::class, 'test2']);
});
Router.php (Router Class):
<?php
namespace Core;
use Core\RouterHandler;
use Closure;
class Router
{
protected static $routes = [];
protected static $middlewares = [];
protected static string $uriMethod;
protected static string $trigger;
/**
* start
* START THE ROUTER IN INDEX.PHP
* #param Router $router
* #return void
*/
public static function start()
{
$routerHandler = new RouterHandler(self::$routes);
$routerHandler->run();
}
/**
* constructByMethod
* CONSTRUCT THE ROUTE OBJECT WHEN CALLED BY THE MAINS METHODS
* #param string $uri
* #param array $trigger
* #param string $uriMethod
* #return object
*/
private static function constructByMethod(string $uri, array $trigger, string $uriMethod): object
{
self::$uriMethod = $uriMethod;
self::$trigger = $trigger[0].'::'.$trigger[1];
self::$routes[$uriMethod][self::$trigger]['uri'] = $uri;
self::$routes[$uriMethod][self::$trigger]['uriMethod'] = $uriMethod;
self::$routes[$uriMethod][self::$trigger]['controller'] = $trigger[0];
self::$routes[$uriMethod][self::$trigger]['action'] = $trigger[1];
if (!empty(self::$middlewares)) {
self::$routes[$uriMethod][self::$trigger]['middlewares'] = self::$middlewares;
}
self::$middlewares = [];
return new static();
}
/**
* get
* MAIN METHOD TO CONSTRUCT GET ROUTE
* #param string $uri
* #param array $trigger
* #return object
*/
public static function get(string $uri, array $trigger): object
{
self::constructByMethod($uri, $trigger, 'GET');
return new static();
}
/**
* post
* MAIN METHOD TO CONSTRUCT POST ROUTE
* #param string $uri
* #param array $trigger
* #return object
*/
public static function post(string $uri, array $trigger): object
{
self::constructByMethod($uri, $trigger, 'POST');
return new static();
}
/**
* put
* MAIN METHOD TO CONSTRUCT POST ROUTE
* #param string $uri
* #param array $trigger
* #return object
*/
public static function put(string $uri, array $trigger): object
{
self::constructByMethod($uri, $trigger, 'PUT');
return new static();
}
/**
* delete
* MAIN METHOD TO CONSTRUCT DELETE ROUTE
* #param string $uri
* #param array $trigger
* #return object
*/
public static function delete(string $uri, array $trigger): object
{
self::constructByMethod($uri, $trigger, 'DELETE');
return new static();
}
public static function group($callback)
{
$callback();
}
/**
* name
* ADD A NAME TO A ROUTE
* #param string $name
* #return object
*/
public static function name(string $name): object
{
self::$routes[self::$uriMethod][self::$trigger]['name'] = $name;
return new static();
}
/**
* middleware
* ADD A GROUP OF MIDDLEWARE FOR A ROUTES
* #param array|null $middlewares
* #return object
*/
public static function middleware(array|null $middlewares): object
{
self::$middlewares = $middlewares;
return new static();
}
/**
* where
* ADD A REGEX CONDITION FOR A VARIABLE PARAMETER IN ROUTE
* #param array $where
* #return object
*/
public static function where(array $where): object
{
self::$routes[self::$uriMethod][self::$trigger]['where'] = $where;
return new static();
}
}
What to do after that?
public static function group($callback)
{
$callback();
}
Tried all ways, but I can't understand how to group the routes using closure.
I need to understand how to use the closure in this specific case.
First, you'll need to use the method Closure::call, in order to temporarily bind the group handler (function(){...}) to the instance of the router.
After that you'll need to execute the group handler. Then:
each group inside it will be binded and executed as well (as described above), and
each route defined inside it will be added to the router.
Below is a short example of my code, regarding adding a group to the route collection, with detailed comments (see RouteCollection::group method).
Note that I add groups/routes to a RouteCollection, which is further added to my Router. Instead you are adding them directly to your Router.
Further down under I also posted my whole RouteCollection code, for better understanding.
Note: You are using static methods/properties. I suggest not to use any at all. Instead, you should use dependency injection.
Short code version:
RouteCollectionInterface (short version, regarding binding & executing a group):
<?php
namespace PajuranCodes\Router;
use Closure;
/**
* An interface to a collection of routes.
*
* #author pajurancodes https://github.com/pajurancodes
*/
interface RouteCollectionInterface extends \Countable, \IteratorAggregate {
/**
* Add a group.
*
* #param string $pattern A group pattern.
* #param Closure $handler A group handler.
* #return static
*/
public function group(string $pattern, Closure $handler): static;
}
RouteCollection (short version, regarding binding & executing a group):
<?php
namespace PajuranCodes\Router;
use function array_pop;
use PajuranCodes\Router\{
RouteCollectionInterface,
};
use Closure;
/**
* A collection of routes.
*
* #author pajurancodes https://github.com/pajurancodes
*/
class RouteCollection implements RouteCollectionInterface {
[...]
/**
* A list of group patterns as an indexed array.
*
* {#internal Each time a group handler is executed, the group
* pattern is pushed to this list. When a route is added to the
* routes list (inside the scope of a group handler), the route
* pattern is prefixed with the string formed by concatenating
* all group patterns saved in this list.}
*
* #var string[]
*/
private array $groupPatterns = [];
/**
* #inheritDoc
*/
public function group(string $pattern, Closure $handler): static {
$this->addGroup($pattern, $handler);
return $this;
}
/**
* Add a group.
*
* #param string $pattern A group pattern.
* #param Closure $handler A group handler.
* #return static
*/
private function addGroup(string $pattern, Closure $handler): static {
$this->saveGroupPattern($pattern);
$this->executeGroupHandler($handler);
/*
* Remove the last group pattern from the group patterns list.
* This step is performed only after all calls for adding
* groups/routes inside the scope of the current group
* handler have finished their processing.
*/
$this->popLastGroupPattern();
return $this;
}
/**
* Save a group pattern.
*
* #param string $pattern A group pattern.
* #return static
*/
private function saveGroupPattern(string $pattern): static {
$this->groupPatterns[] = $pattern;
return $this;
}
/**
* Execute a group handler.
*
* {#internal This method temporarily binds the given group handler to
* the instance of the route collection - defined by the argument of
* Closure::call - and executes it. Inside the scope of the group handler,
* the route collection will be accessed using the keyword "$this".}
*
* #link https://www.php.net/manual/en/closure.call.php Closure::call
*
* #param Closure $handler A group handler.
* #return static The value returned by executing the group handler.
*/
private function executeGroupHandler(Closure $handler): static {
$handler->call($this);
return $this;
}
/**
* Pop and return the last group pattern in the list of group patterns.
*
* The list will be shortened by one element.
*
* #return string|null The last group pattern, or null if the list is empty.
*/
private function popLastGroupPattern(): ?string {
return array_pop($this->groupPatterns);
}
[...]
}
Long code version:
RouteCollectionInterface (complete version):
<?php
namespace PajuranCodes\Router;
use Closure;
use PajuranCodes\Router\RouteInterface;
/**
* An interface to a collection of routes.
*
* #author pajurancodes https://github.com/pajurancodes
*/
interface RouteCollectionInterface extends \Countable, \IteratorAggregate {
/**
* Add a group.
*
* #param string $pattern A group pattern.
* #param Closure $handler A group handler.
* #return static
*/
public function group(string $pattern, Closure $handler): static;
/**
* Add a route for one or more HTTP methods.
*
* #param string|string[] $methods One or more HTTP methods.
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
public function route(
string|array $methods,
string $pattern,
string|array|object $handler
): RouteInterface;
/**
* Add a route for all HTTP methods.
*
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
public function routeForAllMethods(string $pattern, string|array|object $handler): RouteInterface;
/**
* Add a route for the HTTP method GET.
*
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
public function get(string $pattern, string|array|object $handler): RouteInterface;
/**
* Add a route for the HTTP method HEAD.
*
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
public function head(string $pattern, string|array|object $handler): RouteInterface;
/**
* Add a route for the HTTP method POST.
*
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
public function post(string $pattern, string|array|object $handler): RouteInterface;
/**
* Add a route for the HTTP method PUT.
*
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
public function put(string $pattern, string|array|object $handler): RouteInterface;
/**
* Add a route for the HTTP method DELETE.
*
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
public function delete(string $pattern, string|array|object $handler): RouteInterface;
/**
* Add a route for the HTTP method CONNECT.
*
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
public function connect(string $pattern, string|array|object $handler): RouteInterface;
/**
* Add a route for the HTTP method OPTIONS.
*
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
public function options(string $pattern, string|array|object $handler): RouteInterface;
/**
* Add a route for the HTTP method TRACE.
*
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
public function trace(string $pattern, string|array|object $handler): RouteInterface;
/**
* Add a route for the HTTP method PATCH.
*
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
public function patch(string $pattern, string|array|object $handler): RouteInterface;
/**
* Get a route by id.
*
* #param string $id A route id.
* #return RouteInterface The found route.
* #throws \UnexpectedValueException No route found.
*/
public function getRouteById(string $id): RouteInterface;
/**
* Get a route by name.
*
* #param string $name A route name.
* #return RouteInterface The found route.
* #throws \UnexpectedValueException No route found.
*/
public function getRouteByName(string $name): RouteInterface;
/**
* Check if a route exists in the collection.
*
* #param string $id A route id.
* #return bool True if the specified route id exists, or false otherwise.
*/
public function exists(string $id): bool;
/**
* Remove a route from the collection.
*
* #param string $id A route Id.
* #return static
*/
public function remove(string $id): static;
/**
* Get all routes from the collection.
*
* #return RouteInterface[] All routes in the collection.
*/
public function all(): array;
/**
* Remove all routes from the collection.
*
* #return static
*/
public function clear(): static;
/**
* Check if the collection is empty.
*
* #return bool True if the collection is empty, or false otherwise.
*/
public function isEmpty(): bool;
/**
* Count the routes in the collection.
*
* #return int Number of routes in the collection.
*/
public function count(): int;
/**
* Get an iterator to iterate through the collection.
*
* #return \Traversable The routes iterator.
*/
public function getIterator(): \Traversable;
}
RouteCollection (complete version):
<?php
namespace PajuranCodes\Router;
use function count;
use function implode;
use function array_pop;
use function array_key_exists;
use PajuranCodes\Router\{
Route,
RouteInterface,
RouteCollectionInterface,
};
use Closure;
use Fig\Http\Message\RequestMethodInterface as RequestMethod;
/**
* A collection of routes.
*
* #author pajurancodes https://github.com/pajurancodes
*/
class RouteCollection implements RouteCollectionInterface {
/**
* A string to be concatenated to a counter in order to form a route id.
*
* #var string
*/
private const ROUTE_ID_PREFIX = 'route';
/**
* A list of allowed HTTP methods.
*
* #link https://tools.ietf.org/html/rfc7231#section-4 4. Request Methods
* #link https://www.iana.org/assignments/http-methods/http-methods.xhtml Hypertext Transfer Protocol (HTTP) Method Registry
* #link https://tools.ietf.org/html/rfc5789 PATCH Method for HTTP
*
* #var string[]
*/
private const ROUTE_ALLOWED_METHODS = [
RequestMethod::METHOD_GET,
RequestMethod::METHOD_HEAD,
RequestMethod::METHOD_POST,
RequestMethod::METHOD_PUT,
RequestMethod::METHOD_DELETE,
RequestMethod::METHOD_CONNECT,
RequestMethod::METHOD_OPTIONS,
RequestMethod::METHOD_TRACE,
RequestMethod::METHOD_PATCH,
];
/**
* A list of routes as an associative array.
*
* The key of each list item is a route id
* built from a prefix string and a counter.
*
* #var RouteInterface[]
*/
private array $routes = [];
/**
* A list of group patterns as an indexed array.
*
* {#internal Each time a group handler is executed, the group
* pattern is pushed to this list. When a route is added to the
* routes list (inside the scope of a group handler), the route
* pattern is prefixed with the string formed by concatenating
* all group patterns saved in this list.}
*
* #var string[]
*/
private array $groupPatterns = [];
/**
* A counter used to be prefixed with a given string in order to form a route id.
*
* {#internal After a route is added to the
* routes list this counter is incremented.}
*
* #var int
*/
private int $routeIdCounter = 0;
/**
* #inheritDoc
*/
public function group(string $pattern, Closure $handler): static {
$this->addGroup($pattern, $handler);
return $this;
}
/**
* Add a group.
*
* #param string $pattern A group pattern.
* #param Closure $handler A group handler.
* #return static
*/
private function addGroup(string $pattern, Closure $handler): static {
$this->saveGroupPattern($pattern);
$this->executeGroupHandler($handler);
/*
* Remove the last group pattern from the group patterns list.
* This step is performed only after all calls for adding
* groups/routes inside the scope of the current group
* handler have finished their processing.
*/
$this->popLastGroupPattern();
return $this;
}
/**
* Save a group pattern.
*
* #param string $pattern A group pattern.
* #return static
*/
private function saveGroupPattern(string $pattern): static {
$this->groupPatterns[] = $pattern;
return $this;
}
/**
* Execute a group handler.
*
* {#internal This method temporarily binds the given group handler to
* the instance of the route collection - defined by the argument of
* Closure::call - and executes it. Inside the scope of the group handler,
* the route collection will be accessed using the keyword "$this".}
*
* #link https://www.php.net/manual/en/closure.call.php Closure::call
*
* #param Closure $handler A group handler.
* #return static The value returned by executing the group handler.
*/
private function executeGroupHandler(Closure $handler): static {
$handler->call($this);
return $this;
}
/**
* Pop and return the last group pattern in the list of group patterns.
*
* The list will be shortened by one element.
*
* #return string|null The last group pattern, or null if the list is empty.
*/
private function popLastGroupPattern(): ?string {
return array_pop($this->groupPatterns);
}
/**
* #inheritDoc
*/
public function route(
string|array $methods,
string $pattern,
string|array|object $handler
): RouteInterface {
return $this->addRoute($methods, $pattern, $handler);
}
/**
* #inheritDoc
*/
public function routeForAllMethods(string $pattern, string|array|object $handler): RouteInterface {
return $this->addRoute(self::ROUTE_ALLOWED_METHODS, $pattern, $handler);
}
/**
* #inheritDoc
*/
public function get(string $pattern, string|array|object $handler): RouteInterface {
return $this->addRoute(RequestMethod::METHOD_GET, $pattern, $handler);
}
/**
* #inheritDoc
*/
public function head(string $pattern, string|array|object $handler): RouteInterface {
return $this->addRoute(RequestMethod::METHOD_HEAD, $pattern, $handler);
}
/**
* #inheritDoc
*/
public function post(string $pattern, string|array|object $handler): RouteInterface {
return $this->addRoute(RequestMethod::METHOD_POST, $pattern, $handler);
}
/**
* #inheritDoc
*/
public function put(string $pattern, string|array|object $handler): RouteInterface {
return $this->addRoute(RequestMethod::METHOD_PUT, $pattern, $handler);
}
/**
* #inheritDoc
*/
public function delete(string $pattern, string|array|object $handler): RouteInterface {
return $this->addRoute(RequestMethod::METHOD_DELETE, $pattern, $handler);
}
/**
* #inheritDoc
*/
public function connect(string $pattern, string|array|object $handler): RouteInterface {
return $this->addRoute(RequestMethod::METHOD_CONNECT, $pattern, $handler);
}
/**
* #inheritDoc
*/
public function options(string $pattern, string|array|object $handler): RouteInterface {
return $this->addRoute(RequestMethod::METHOD_OPTIONS, $pattern, $handler);
}
/**
* #inheritDoc
*/
public function trace(string $pattern, string|array|object $handler): RouteInterface {
return $this->addRoute(RequestMethod::METHOD_TRACE, $pattern, $handler);
}
/**
* #inheritDoc
*/
public function patch(string $pattern, string|array|object $handler): RouteInterface {
return $this->addRoute(RequestMethod::METHOD_PATCH, $pattern, $handler);
}
/**
* Add a route.
*
* #param string|string[] $methods One or more HTTP methods.
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
private function addRoute(
string|array $methods,
string $pattern,
string|array|object $handler
): RouteInterface {
$this
->validateRouteMethods($methods)
->validateRouteHandler($handler)
;
$prefixedPattern = $this->prefixRoutePatternWithGroupPatterns($pattern);
$route = $this->createRoute($methods, $prefixedPattern, $handler);
return $this->saveRoute($route);
}
/**
* Validate a list of route methods.
*
* #param string|string[] $methods One or more HTTP methods.
* #return static
* #throws \InvalidArgumentException The list of HTTP methods is empty.
*/
private function validateRouteMethods(string|array $methods): static {
if (empty($methods)) {
throw new \InvalidArgumentException('One or more HTTP methods must be provided.');
}
return $this;
}
/**
* Validate a route handler.
*
* #param string|array|object $handler A route handler.
* #return static
* #throws \InvalidArgumentException An empty route handler.
*/
private function validateRouteHandler(string|array|object $handler): static {
if (empty($handler)) {
throw new \InvalidArgumentException('The route handler can not be empty.');
}
return $this;
}
/**
* Prefix a route pattern with the pattern formed by
* concatenating the list of group patterns in a single string.
*
* #param string $pattern A route pattern.
* #return string The prefixed route pattern.
*/
private function prefixRoutePatternWithGroupPatterns(string $pattern): string {
return $this->getConcatenatedGroupPatterns() . $pattern;
}
/**
* Get the pattern formed by concatenating the
* list of group patterns in a single string.
*
* #return string The resulted pattern.
*/
private function getConcatenatedGroupPatterns(): string {
return $this->groupPatterns ? implode('', $this->groupPatterns) : '';
}
/**
* Create a route.
*
* #param string|string[] $methods One or more HTTP methods.
* #param string $pattern A route pattern.
* #param string|array|object $handler A route handler.
* #return RouteInterface The route.
*/
private function createRoute(
string|array $methods,
string $pattern,
string|array|object $handler
): RouteInterface {
return new Route($methods, $pattern, $handler);
}
/**
* Save a route.
*
* Before saving, an id is assigned to the route.
*
* #param RouteInterface $route A route.
* #return RouteInterface The route.
*/
private function saveRoute(RouteInterface $route): RouteInterface {
$id = $this->buildRouteId();
$route->setId($id);
$this->routes[$id] = $route;
$this->routeIdCounter++;
return $route;
}
/**
* Build a route id.
*
* The id is built by concatenating the
* route id prefix and the route id counter.
*
* #return string The route id.
*/
private function buildRouteId(): string {
return self::ROUTE_ID_PREFIX . (string) $this->routeIdCounter;
}
/**
* #inheritDoc
*/
public function getRouteById(string $id): RouteInterface {
if (!$this->exists($id)) {
throw new \UnexpectedValueException(
'A route with the id "' . $id . '" could not be found.'
);
}
return $this->routes[$id];
}
/**
* #inheritDoc
*/
public function getRouteByName(string $name): RouteInterface {
foreach ($this->routes as $route) {
if ($route->getName() === $name) {
return $route;
}
}
throw new \UnexpectedValueException(
'A route with the name "' . $name . '" could not be found.'
);
}
/**
* #inheritDoc
*/
public function exists(string $id): bool {
return array_key_exists($id, $this->routes);
}
/**
* #inheritDoc
*/
public function remove(string $id): static {
if ($this->exists($id)) {
unset($this->routes[$id]);
}
return $this;
}
/**
* #inheritDoc
*/
public function all(): array {
return $this->routes;
}
/**
* #inheritDoc
*/
public function clear(): static {
$this->routes = [];
return $this;
}
/**
* #inheritDoc
*/
public function isEmpty(): bool {
return !($this->count() > 0);
}
/**
* #inheritDoc
*/
public function count(): int {
return count($this->routes);
}
/**
* #inheritDoc
*/
public function getIterator(): \Traversable {
return new \ArrayIterator($this->routes);
}
}

Convert Laravel Script into normal php for WG Openid Login

ive an Laravel Openid Script for Wargaming Openid Login. at the moment i dont use laravel. So i will convert it into an normal PHP Script for an MVC Model based CMS called ilch 2.x
For iLch i do some plugins. But im so stupid to convert it.
The Problems comes from the request parts of this script. but i cant solf the problems.
My Skills are not so good.
`
<?php
declare(strict_types=1);
namespace Azate\Laravel\WargamingAuth;
use GuzzleHttp\Client as GuzzleClient;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Http\Request;
/**
* Class WargamingAuth
*
* #package Azate\Laravel\WargamingAuth
*/
class WargamingAuth
{
/**
* Config repository.
*
* #var ConfigRepository
*/
protected $configRepository;
/**
* Illuminate request class.
*
* #var Request
*/
protected $request;
/**
* Illuminate url class.
*
* #var UrlGenerator
*/
protected $urlGenerator;
/**
* Region.
*
* #var string
*/
protected $region;
/**
* Realm
*
* #var string
*/
protected $realm;
/**
* Callback url.
*
* #var string
*/
protected $callbackUrl;
/**
* Creates new instance.
*
* #param ConfigRepository $configRepository
* #param Request $request
* #param UrlGenerator $urlGenerator
*/
public function __construct(
ConfigRepository $configRepository,
Request $request,
UrlGenerator $urlGenerator
) {
$this->configRepository = $configRepository;
$this->request = $request;
$this->urlGenerator = $urlGenerator;
$this->region = $this->configRepository->get('wargamingAuth.defaultRegion');
$this->realm = $this->configRepository->get('app.url');
$this->callbackUrl = $this->urlGenerator->route(
$this->configRepository->get('wargamingAuth.callbackRoute')
);
}
/**
* Returns the region.
*
* #return string
*/
public function getRegion(): string
{
return $this->region;
}
/**
* Set the region.
*
* #param string $region
*/
public function setRegion(string $region)
{
$this->region = $region;
}
/**
* Returns the realm.
*
* #return string
*/
public function getRealm(): string
{
return $this->realm;
}
/**
* Set the realm.
*
* #param string $realm
*/
public function setRealm(string $realm)
{
$this->realm = $realm;
}
/**
* Returns the OpenID URL.
*
* #return string
*/
public function getOpenIdUrl(): string
{
return 'https://' . $this->region . '.wargaming.net/id/openid/';
}
/**
* Returns the redirect URL.
*
* #return string
*/
public function redirectUrl(): string
{
$params = [
'openid.ax.if_available' => 'ext0,ext1',
'openid.ax.mode' => 'fetch_request',
'openid.ax.type.ext0' => 'http://axschema.openid.wargaming.net/spa/id',
'openid.ax.type.ext1' => 'http://axschema.org/namePerson/friendly',
'openid.claimed_id' => 'http://specs.openid.net/auth/2.0/identifier_select',
'openid.identity' => 'http://specs.openid.net/auth/2.0/identifier_select',
'openid.mode' => 'checkid_setup',
'openid.ns' => 'http://specs.openid.net/auth/2.0',
'openid.ns.ax' => 'http://openid.net/srv/ax/1.0',
'openid.realm' => $this->realm,
'openid.return_to' => $this->callbackUrl,
];
return $this->getOpenIdUrl() . '?' . http_build_query($params, '', '&');
}
/**
* OpenID Positive Assertions.
*
* #return bool
*/
private function isPositiveAssertion(): bool
{
$hasFields = $this->request->has([
'openid_assoc_handle',
'openid_claimed_id',
'openid_identity',
'openid_mode',
'openid_ns',
'openid_op_endpoint',
'openid_response_nonce',
'openid_return_to',
'openid_sig',
'openid_signed',
]);
$isModeIdRes = $this->request->get('openid_mode') === 'id_res';
return $hasFields && $isModeIdRes;
}
/**
* OpenID Verifying the Return URL.
*
* #return bool
*/
public function verifyingReturnUrl(): bool
{
return $this->request->get('openid_return_to') === $this->request->url();
}
/**
* Get param list for OpenID validation
*
* #return array
*/
private function getOpenIdValidationParams(): array
{
$params = [];
$signedParams = explode(',', $this->request->get('openid_signed'));
foreach ($signedParams as $item) {
$params['openid.' . $item] = $this->request->get('openid_' . str_replace('.', '_', $item));
}
$params['openid.mode'] = 'check_authentication';
$params['openid.sig'] = $this->request->get('openid_sig');
return $params;
}
/**
* OpenID Verifying Signatures (Wargaming uses Direct Verification).
*
* #return bool
*
* #throws \GuzzleHttp\Exception\GuzzleException
*/
public function verifyingSignatures(): bool
{
$httpClient = new GuzzleClient;
$response = $httpClient->request('POST', $this->getOpenIdUrl(), [
'form_params' => $this->getOpenIdValidationParams(),
]);
$content = $response->getBody()->getContents();
return strpos($content, 'is_valid:true') !== false;
}
/**
* Process to verify an OpenID assertion.
*
* #return bool
*
* #throws \GuzzleHttp\Exception\GuzzleException
*/
public function verify(): bool
{
return $this->isPositiveAssertion()
&& $this->verifyingReturnUrl()
&& $this->verifyingSignatures();
}
/**
* Returns the user data.
*
* #return array
*/
public function user(): array
{
return [
'id' => $this->request->get('openid_ax_value_ext0_1'),
'nickname' => $this->request->get('openid_ax_value_ext1_1'),
];
}
}
`
I hope i can get help from you
I fail with the requests especially with has()

Laravel Nova pass value of one filter to another filter

I am trying to filter Laravel Nova resource (Reviews) data using 2 'select-filters'.
I have a filter A = Manufacturers and filter B = Models.
A Manufacturer has many Models. I have manufacturer and model column in products table.
'Model' filter by default show all the values in the select dropdown. I want to reduce the select options in the 'Model' filter when 'Manufacturer' is selected.
so, for example: When Manufacturer = "Apple" then 'Model' filter should show only Apple 'Models'.
In my Review Resource, I have below code:
/**
* Get the filters available for the resource.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function filters(Request $request)
{
return [
new Manufacturer(),
new Model(),
];
}
Manufacturer Filter code
class Manufacturer extends Filter
{
/**
* The filter's component.
*
* #var string
*/
public $component = 'select-filter';
/**
* Apply the filter to the given query.
*
* #param \Illuminate\Http\Request $request
* #param \Illuminate\Database\Eloquent\Builder $query
* #param mixed $value
*
* #return \Illuminate\Database\Eloquent\Builder
*/
public function apply(Request $request, $query, $value)
{
return $query->whereHas('product', function ($query) use ($value) {
$query->where('manufacturer', $value);
});
}
/**
* Get the filter's available options.
*
* #param \Illuminate\Http\Request $request
*
* #return array
*/
public function options(Request $request)
{
return Product::select('manufacturer')
->withoutGlobalScopes()
->withoutTrashed()
->groupBy('manufacturer')
->orderBy('manufacturer')
->pluck('manufacturer')
->mapWithKeys(function ($manufacturer) {
return [$manufacturer => strtolower($manufacturer)];
})
->toArray();
}
}
Model Filter code
class Model extends Filter
{
/**
* The filter's component.
*
* #var string
*/
public $component = 'select-filter';
/**
* Apply the filter to the given query.
*
* #param \Illuminate\Http\Request $request
* #param \Illuminate\Database\Eloquent\Builder $query
* #param mixed $value
*
* #return \Illuminate\Database\Eloquent\Builder
*/
public function apply(Request $request, $query, $value)
{
return $query->whereHas('product', function ($query) use ($value) {
$query->where('model', $value);
});
}
/**
* Get the filter's available options.
*
* #param \Illuminate\Http\Request $request
*
* #return array
*/
public function options(Request $request)
{
//
//
//I want to add a condition below ->where('manufacturer', $manufacturer)
//
//
return Product::select('model')
->withoutGlobalScopes()
->withoutTrashed()
->groupBy('model')
->orderBy('model')
->pluck('model')
->mapWithKeys(function ($model) {
return [$model => strtolower($model)];
})
->toArray();
}
}
I tried to decode $request to get the filter values but returns null.
I found the library that helps achieve exactly what I wanted.
The library can be found here: https://github.com/awesome-nova/dependent-filter
Once the above library is installed, the two filters can be set as shown below:
Filter A
<?php
namespace App\Nova\Filters;
use Illuminate\Http\Request;
use App\Models\Product;
use AwesomeNova\Filters\DependentFilter;
class Manufacturer extends DependentFilter
{
/**
* Name of filter.
*
* #var string
*/
public $name = 'Manufacturer';
/**
* Attribute name of filter. Also it is key of filter.
*
* #var string
*/
public $attribute = 'manufacturer';
/**
* The filter's component.
*
* #var string
*/
public $component = 'awesome-nova-dependent-filter';
/**
* Apply the filter to the given query.
*
* #param \Illuminate\Http\Request $request
* #param \Illuminate\Database\Eloquent\Builder $query
* #param mixed $value
* #return \Illuminate\Database\Eloquent\Builder
*/
public function apply(Request $request, $query, $value)
{
return $query->whereHas('product', function ($query) use ($value) {
$query->where('manufacturer', $value);
});
}
/**
* Get the filter's available options.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function options(Request $request, array $filters = [])
{
return Product::select('manufacturer')
->pluck('manufacturer')
->mapWithKeys(function ($manufacturer) {
return [$manufacturer => $manufacturer];
})->toArray();
}
Filter B
<?php
namespace App\Nova\Filters;
use App\Models\Product;
use Illuminate\Http\Request;
use AwesomeNova\Filters\DependentFilter;
class Model extends DependentFilter
{
/**
* Name of filter.
*
* #var string
*/
public $name = 'Model';
/**
* Attribute name of filter. Also it is key of filter.
*
* #var string
*/
public $attribute = 'model';
/**
* The filter's component.
*
* #var string
*/
public $component = 'awesome-nova-dependent-filter';
/**
* The filter's dependentOf.
*
* #var array
*/
public $dependentOf = ['manufacturer'];
public $hideWhenEmpty = true;
/**
* Apply the filter to the given query.
*
* #param \Illuminate\Http\Request $request
* #param \Illuminate\Database\Eloquent\Builder $query
* #param mixed $value
* #return \Illuminate\Database\Eloquent\Builder
*/
public function apply(Request $request, $query, $value)
{
return $query->whereHas('product', function ($query) use ($value) {
$query->where('model', $value);
});
}
/**
* Get the filter's available options.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function options(Request $request, array $filters = [])
{
return Product::select('model')
->where('manufacturer', $filters['manufacturer'])
->pluck('model')
->mapWithKeys(function ($model) {
return [$model => $model];
})->toArray();
}
}
Resource File
public function filters(Request $request)
{
return [
Manufacturer::make(),
Model::make(),
];
}

Object of Class App\PageStatus (DateTime?) could not be converted to int

I am using nova-dependency-container but get the following error Object of Class App\PageStatus could not be converted to int. This error appears when creating a new page/resource in Laravel Nova or when trying to view a page/resource in Laravel Nova.
However, the page/resource still gets created... but when trying to view the page/resource I just get this error and see a blank page...
This is my app/Nova/Page.php model
<?php
namespace App\Nova;
use Epartment\NovaDependencyContainer\HasDependencies;
use Epartment\NovaDependencyContainer\NovaDependencyContainer;
use Froala\NovaFroalaField\Froala;
use Gwd\SeoMeta\SeoMeta;
use Illuminate\Http\Request;
use Inspheric\Fields\Indicator;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\DateTime;
use App\PageStatus;
class Page extends Resource
{
use HasDependencies;
/**
* The model the resource corresponds to.
*
* #var string
*/
public static $model = \App\Page::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* #var string
*/
public static $title = 'title';
/**
* The columns that should be searched.
*
* #var array
*/
public static $search = [
'title',
'slug'
];
/**
* The logical group associated with the resource.
*
* #var string
*/
public static $group = 'Pages & Posts';
/**
* Get the fields displayed by the resource.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function fields(Request $request)
{
return [
ID::make('ID', 'id')->asBigInt(),
Text::make('Title')
->rules('required', 'max:255'),
Text::make('Slug', 'slug')
->hideFromIndex()
->creationRules('unique:pages,slug')
->rules('required', 'alpha_dash', 'max:80'),
Froala::make('Content')
->hideFromIndex()
->rules('required'),
Indicator::make('Status', function() {
return $this->pageStatus->status;
})
->labels([
'publish' => 'Publish',
'future' => 'Future',
'draft' => 'Draft',
'pending' => 'Pending',
'private' => 'Privat'
])
->colors([
'publish' => 'green',
'future' => 'purple',
'draft' => 'blue',
'pending' => 'orange',
'private' => 'red'
]),
BelongsTo::make('Status', 'pageStatus', 'App\Nova\PageStatus')
->onlyOnForms(),
NovaDependencyContainer::make([
DateTime::make('When to Publish', 'publish_at')
->format('DD.MM.YYYY # HH:MM:SS')
->rules('required', 'date_format:Y-m-d H:i:s')
])->dependsOn('pageStatus', PageStatus::getIdByStatus('future')),
BelongsTo::make('Author', 'user', 'App\Nova\User'),
SeoMeta::make('SEO', 'seo_meta'),
];
}
/**
* Get the cards available for the request.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function cards(Request $request)
{
return [];
}
/**
* Get the filters available for the resource.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function filters(Request $request)
{
return [];
}
/**
* Get the lenses available for the resource.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function lenses(Request $request)
{
return [];
}
/**
* Get the actions available for the resource.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function actions(Request $request)
{
return [];
}
}
app/Nova/PageStatus.php model:
<?php
namespace App\Nova;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
class PageStatus extends Resource
{
/**
* The model the resource corresponds to.
*
* #var string
*/
public static $model = \App\PageStatus::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* #var string
*/
public static $title = 'label';
/**
* The columns that should be searched.
*
* #var array
*/
public static $search = [
'status', 'label'
];
/**
* Default ordering for index query.
*
* #var array
*/
public static $sort = [
'id' => 'asc'
];
/**
* The logical group associated with the resource.
*
* #var string
*/
public static $group = 'Pages & Posts';
/**
* Build an "index" query for the given resource.
*
* #param \Laravel\Nova\Http\Requests\NovaRequest $request
* #param \Illuminate\Database\Eloquent\Builder $query
* #return \Illuminate\Database\Eloquent\Builder
*/
public static function indexQuery(NovaRequest $request, $query)
{
if (empty($request->get('orderBy'))) {
$query->getQuery()->orders = [];
return $query->orderBy(key(static::$sort), reset(static::$sort));
}
return $query;
}
/**
* Get the fields displayed by the resource.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Text::make('Status', 'status')
->required(),
Text::make('Label', 'label')
->required(),
];
}
/**
* Get the cards available for the request.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function cards(Request $request)
{
return [];
}
/**
* Get the filters available for the resource.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function filters(Request $request)
{
return [];
}
/**
* Get the lenses available for the resource.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function lenses(Request $request)
{
return [];
}
/**
* Get the actions available for the resource.
*
* #param \Illuminate\Http\Request $request
* #return array
*/
public function actions(Request $request)
{
return [];
}
}
App/Page.php model:
<?php
namespace App;
use Gwd\SeoMeta\Traits\SeoSitemapTrait;
use Illuminate\Database\Eloquent\Model;
use Gwd\SeoMeta\Traits\SeoMetaTrait;
class Page extends Model
{
use SeoMetaTrait, SeoSitemapTrait;
/*
* In order to have set the auth user as default user when creating a page
*/
public function __construct(array $attributes = [])
{
if (! isset($attributes['user_id']) && auth()->check()) {
$attributes['user_id'] = auth()->user()->id;
}
parent::__construct($attributes);
}
/**
* #Protected_variables
*/
protected $table = 'pages';
protected $guarded = ['id'];
protected $casts = [
'publish_at' => 'datetime',
'created_at' => 'datetime',
'updated_at' => 'datetime'
];
/**
* #Public_variables
*/
/**
* #Relationships
*/
public function user()
{
return $this->belongsTo('App\User');
}
public function pageStatus()
{
return $this->belongsTo('App\PageStatus');
}
/**
* #Attributes
*/
/**
* #Custom_functions
*/
/**
* Get the Page url by item
*
* #return string
*/
public function getSitemapItemUrl(): String
{
return route('page.show', $this->slug);
}
/**
* Query all the Page items which should be
* part of the sitemap (crawlable for google).
*
* #return Page[]|\Illuminate\Database\Eloquent\Collection
*/
public static function getSitemapItems()
{
return static::all();
}
}
App/PageStatus.php model:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class PageStatus extends Model
{
/**
* #Protected_variables
*/
protected $table = 'page_statuses';
protected $guarded = ['id'];
/**
* #Public_variables
*/
/**
* #Relationships
*/
public function products()
{
return $this->hasMany('App\Product');
}
/**
* #Attributes
*/
/**
* #Custom_functions
*/
public static function getPageStatusesFilterArray()
{
$page_statuses = PageStatus::all('id', 'label');
$array = array();
foreach($page_statuses as $page_status){
$array[$page_status->label] = $page_status->id;
}
return $array;
}
public static function getIdByStatus($status)
{
return self::where('status', $status)->first()->id;
}
}
Update
pageStatus migration file:
class CreatePageStatusesTable extends Migration
{
/**
* Run the migrations.
*
* #return void
*/
public function up()
{
Schema::create('page_statuses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('status')->index()->unique();
$table->string('label');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* #return void
*/
public function down()
{
Schema::dropIfExists('page_statuses');
}
}
I found the problem. I have to change ->dependsOn('pageStatus', PageStatus::getIdByStatus('future')) to ->dependsOn('pageStatus.id', PageStatus::getIdByStatus('future')).
The .id was missing to specify the column of the postStatus.

Upload Laravel in host

I uploaded my project from wamp to my host.
When I open my site, site shows :
(1/1) InvalidArgumentException
View [welcome] not found.
.....
in FileViewFinder.php line 137
FileViewFinder.php:
<?php
namespace Illuminate\View;
use InvalidArgumentException;
use Illuminate\Filesystem\Filesystem;
class FileViewFinder implements ViewFinderInterface
{
/**
* The filesystem instance.
*
* #var \Illuminate\Filesystem\Filesystem
*/
protected $files;
/**
* The array of active view paths.
*
* #var array
*/
protected $paths;
/**
* The array of views that have been located.
*
* #var array
*/
protected $views = [];
/**
* The namespace to file path hints.
*
* #var array
*/
protected $hints = [];
/**
* Register a view extension with the finder.
*
* #var array
*/
protected $extensions = ['blade.php', 'php', 'css'];
/**
* Create a new file view loader instance.
*
* #param \Illuminate\Filesystem\Filesystem $files
* #param array $paths
* #param array $extensions
* #return void
*/
public function __construct(Filesystem $files, array $paths, array $extensions = null)
{
$this->files = $files;
$this->paths = $paths;
if (isset($extensions)) {
$this->extensions = $extensions;
}
}
/**
* Get the fully qualified location of the view.
*
* #param string $name
* #return string
*/
public function find($name)
{
if (isset($this->views[$name])) {
return $this->views[$name];
}
if ($this->hasHintInformation($name = trim($name))) {
return $this->views[$name] = $this->findNamespacedView($name);
}
return $this->views[$name] = $this->findInPaths($name, $this->paths);
}
/**
* Get the path to a template with a named path.
*
* #param string $name
* #return string
*/
protected function findNamespacedView($name)
{
list($namespace, $view) = $this->parseNamespaceSegments($name);
return $this->findInPaths($view, $this->hints[$namespace]);
}
/**
* Get the segments of a template with a named path.
*
* #param string $name
* #return array
*
* #throws \InvalidArgumentException
*/
protected function parseNamespaceSegments($name)
{
$segments = explode(static::HINT_PATH_DELIMITER, $name);
if (count($segments) != 2) {
throw new InvalidArgumentException("View [$name] has an invalid name.");
}
if (! isset($this->hints[$segments[0]])) {
throw new InvalidArgumentException("No hint path defined for [{$segments[0]}].");
}
return $segments;
}
/**
* Find the given view in the list of paths.
*
* #param string $name
* #param array $paths
* #return string
*
* #throws \InvalidArgumentException
*/
protected function findInPaths($name, $paths)
{
foreach ((array) $paths as $path) {
foreach ($this->getPossibleViewFiles($name) as $file) {
if ($this->files->exists($viewPath = $path.'/'.$file)) {
return $viewPath;
}
}
}
throw new InvalidArgumentException("View [$name] not found.");
}
/**
* Get an array of possible view files.
*
* #param string $name
* #return array
*/
protected function getPossibleViewFiles($name)
{
return array_map(function ($extension) use ($name) {
return str_replace('.', '/', $name).'.'.$extension;
}, $this->extensions);
}
/**
* Add a location to the finder.
*
* #param string $location
* #return void
*/
public function addLocation($location)
{
$this->paths[] = $location;
}
/**
* Prepend a location to the finder.
*
* #param string $location
* #return void
*/
public function prependLocation($location)
{
array_unshift($this->paths, $location);
}
/**
* Add a namespace hint to the finder.
*
* #param string $namespace
* #param string|array $hints
* #return void
*/
public function addNamespace($namespace, $hints)
{
$hints = (array) $hints;
if (isset($this->hints[$namespace])) {
$hints = array_merge($this->hints[$namespace], $hints);
}
$this->hints[$namespace] = $hints;
}
/**
* Prepend a namespace hint to the finder.
*
* #param string $namespace
* #param string|array $hints
* #return void
*/
public function prependNamespace($namespace, $hints)
{
$hints = (array) $hints;
if (isset($this->hints[$namespace])) {
$hints = array_merge($hints, $this->hints[$namespace]);
}
$this->hints[$namespace] = $hints;
}
/**
* Replace the namespace hints for the given namespace.
*
* #param string $namespace
* #param string|array $hints
* #return void
*/
public function replaceNamespace($namespace, $hints)
{
$this->hints[$namespace] = (array) $hints;
}
/**
* Register an extension with the view finder.
*
* #param string $extension
* #return void
*/
public function addExtension($extension)
{
if (($index = array_search($extension, $this->extensions)) !== false) {
unset($this->extensions[$index]);
}
array_unshift($this->extensions, $extension);
}
/**
* Returns whether or not the view name has any hint information.
*
* #param string $name
* #return bool
*/
public function hasHintInformation($name)
{
return strpos($name, static::HINT_PATH_DELIMITER) > 0;
}
/**
* Flush the cache of located views.
*
* #return void
*/
public function flush()
{
$this->views = [];
}
/**
* Get the filesystem instance.
*
* #return \Illuminate\Filesystem\Filesystem
*/
public function getFilesystem()
{
return $this->files;
}
/**
* Get the active view paths.
*
* #return array
*/
public function getPaths()
{
return $this->paths;
}
/**
* Get the namespace to file path hints.
*
* #return array
*/
public function getHints()
{
return $this->hints;
}
/**
* Get registered extensions.
*
* #return array
*/
public function getExtensions()
{
return $this->extensions;
}
}
I tried several times but I could not solve this problem
I also edited the APP_URL in the .env file, but did not change
How can I fix it?
Try to clear your project cache: php artisan config:cache and php artisan cache:clear maybe the cache is looking for the file in a wrong place.
You can connect your host with vagrant ssh , after that go to your project location using CL and run this command: php artisan config:cache to regenerate the configuration.
Hope that helps you!

Categories