Symfony Exception

TypeError

HTTP 500 Internal Server Error

App\Model\Repositories\PropertyRepository::getPropertyByAlias(): Return value must be of type App\Model\Entities\Property, null returned

Exception

TypeError

  1.         return $featuredProperties->get();
  2.     }
  3.     public function getPropertyByAlias(string $alias): Property
  4.     {
  5.         return $this->model->where('alias'$alias)->where('active'1)->first();
  6.     }
  7.     public function getSimilarPropertiesByProperty(Property $property): Collection
  8.     {
  9.         $greaterPriceProperties Property::where('category_id'$property->category_id)
PropertyRepository->getPropertyByAlias() in /home/imobi239/public_html/app/Services/PropertyService.php (line 23)
  1.         $this->propertyRepository $propertyRepository;
  2.     }
  3.     public function getPropertyByAlias(string $alias): Property
  4.     {
  5.         return $this->propertyRepository->getPropertyByAlias($alias);
  6.     }
  7.     public function getSimilarPropertiesByProperty(Property $property): Collection
  8.     {
  9.         return $this->propertyRepository->getSimilarPropertiesByProperty($property);
PropertyService->getPropertyByAlias() in /home/imobi239/public_html/app/Controllers/PropertyController.php (line 23)
  1.         $this->propertyService $propertyService;
  2.     }
  3.     public function index(Request $request): View
  4.     {
  5.         $property $this->propertyService->getPropertyByAlias($request->route('propertyAlias'));
  6.         $propertyDescription "{$property->category->plural_name}";
  7.         
  8.         if (!empty($property->bedrooms) && $property->bedrooms 0) {
  9.             $propertyDescription .= " com {$property->bedrooms} quarto" . ($property->bedrooms 's' '');
  1.         if (static::isCallableWithAtSign($callback) || $defaultMethod) {
  2.             return static::callClass($container$callback$parameters$defaultMethod);
  3.         }
  4.         return static::callBoundMethod($container$callback, function () use ($container$callback$parameters) {
  5.             return $callback(...array_values(static::getMethodDependencies($container$callback$parameters)));
  6.         });
  7.     }
  8.     /**
  9.      * Call a string reference to a class using Class@method syntax.
in /home/imobi239/public_html/vendor/illuminate/container/Util.php :: Illuminate\Container\{closure} (line 41)
  1.      * @param  mixed  ...$args
  2.      * @return mixed
  3.      */
  4.     public static function unwrapIfClosure($value, ...$args)
  5.     {
  6.         return $value instanceof Closure $value(...$args) : $value;
  7.     }
  8.     /**
  9.      * Get the class name of the given parameter's type, if possible.
  10.      *
  1.         if ($container->hasMethodBinding($method)) {
  2.             return $container->callMethodBinding($method$callback[0]);
  3.         }
  4.         return Util::unwrapIfClosure($default);
  5.     }
  6.     /**
  7.      * Normalize the given callback into a Class@method string.
  8.      *
  1.         if (static::isCallableWithAtSign($callback) || $defaultMethod) {
  2.             return static::callClass($container$callback$parameters$defaultMethod);
  3.         }
  4.         return static::callBoundMethod($container$callback, function () use ($container$callback$parameters) {
  5.             return $callback(...array_values(static::getMethodDependencies($container$callback$parameters)));
  6.         });
  7.     }
  8.     /**
  1.             $this->buildStack[] = $className;
  2.             $pushedToBuildStack true;
  3.         }
  4.         $result BoundMethod::call($this$callback$parameters$defaultMethod);
  5.         if ($pushedToBuildStack) {
  6.             array_pop($this->buildStack);
  7.         }
  1.      */
  2.     protected function callControllerCallable(callable $callable, array $parameters = [])
  3.     {
  4.         try {
  5.             return $this->prepareResponse(
  6.                 $this->call($callable$parameters)
  7.             );
  8.         } catch (HttpResponseException $e) {
  9.             return $e->getResponse();
  10.         }
  11.     }
  1.         if (count($middleware) > 0) {
  2.             return $this->callLumenControllerWithMiddleware(
  3.                 $instance$method$routeInfo$middleware
  4.             );
  5.         } else {
  6.             return $this->callControllerCallable(
  7.                 [$instance$method], $routeInfo[2]
  8.             );
  9.         }
  10.     }
  1.         if (! method_exists($instance $this->make($controller), $method)) {
  2.             throw new NotFoundHttpException;
  3.         }
  4.         if ($instance instanceof LumenController) {
  5.             return $this->callLumenController($instance$method$routeInfo);
  6.         } else {
  7.             return $this->callControllerCallable(
  8.                 [$instance$method], $routeInfo[2]
  9.             );
  10.         }
  1.     protected function callActionOnArrayBasedRoute($routeInfo)
  2.     {
  3.         $action $routeInfo[1];
  4.         if (isset($action['uses'])) {
  5.             return $this->prepareResponse($this->callControllerAction($routeInfo));
  6.         }
  7.         foreach ($action as $value) {
  8.             if ($value instanceof Closure) {
  9.                 $callable $value->bindTo(new RoutingClosure);
  1.                 return $this->callActionOnArrayBasedRoute($this['request']->route());
  2.             }));
  3.         }
  4.         return $this->prepareResponse(
  5.             $this->callActionOnArrayBasedRoute($routeInfo)
  6.         );
  7.     }
  8.     /**
  9.      * Call the Closure or invokable on the array based route.
  1.             case Dispatcher::NOT_FOUND:
  2.                 throw new NotFoundHttpException;
  3.             case Dispatcher::METHOD_NOT_ALLOWED:
  4.                 throw new MethodNotAllowedHttpException($routeInfo[1]);
  5.             case Dispatcher::FOUND:
  6.                 return $this->handleFoundRoute($routeInfo);
  7.         }
  8.     }
  9.     /**
  10.      * Handle a route found by the dispatcher.
  1.                 if (isset($this->router->getRoutes()[$method.$pathInfo])) {
  2.                     return $this->handleFoundRoute([true$this->router->getRoutes()[$method.$pathInfo]['action'], []]);
  3.                 }
  4.                 return $this->handleDispatcherResponse(
  5.                     $this->createDispatcher()->dispatch($method$pathInfo)
  6.                 );
  7.             });
  8.         } catch (Throwable $e) {
  9.             return $this->prepareResponse($this->sendExceptionToHandler($e));
  1.                 ->send($this->make('request'))
  2.                 ->through($middleware)
  3.                 ->then($then);
  4.         }
  5.         return $then($this->make('request'));
  6.     }
  7.     /**
  8.      * Prepare the response for sending.
  9.      *
  1.         [$method$pathInfo] = $this->parseIncomingRequest($request);
  2.         try {
  3.             $this->boot();
  4.             return $this->sendThroughPipeline($this->middleware, function ($request) use ($method$pathInfo) {
  5.                 $this->instance(Request::class, $request);
  6.                 if (isset($this->router->getRoutes()[$method.$pathInfo])) {
  7.                     return $this->handleFoundRoute([true$this->router->getRoutes()[$method.$pathInfo]['action'], []]);
  8.                 }
  1.      * @param  \Symfony\Component\HttpFoundation\Request|null  $request
  2.      * @return void
  3.      */
  4.     public function run($request null)
  5.     {
  6.         $response $this->dispatch($request);
  7.         if ($response instanceof SymfonyResponse) {
  8.             $response->send();
  9.         } else {
  10.             echo (string) $response;
Application->run() in /home/imobi239/public_html/public/index.php (line 38)
  1. | the client's browser allowing them to enjoy the creative
  2. | and wonderful application we have prepared for them.
  3. |
  4. */
  5. $app->run();

Stack Trace

TypeError
TypeError:
App\Model\Repositories\PropertyRepository::getPropertyByAlias(): Return value must be of type App\Model\Entities\Property, null returned

  at /home/imobi239/public_html/app/Model/Repositories/PropertyRepository.php:68
  at App\Model\Repositories\PropertyRepository->getPropertyByAlias()
     (/home/imobi239/public_html/app/Services/PropertyService.php:23)
  at App\Services\PropertyService->getPropertyByAlias()
     (/home/imobi239/public_html/app/Controllers/PropertyController.php:23)
  at App\Controllers\PropertyController->index()
     (/home/imobi239/public_html/vendor/illuminate/container/BoundMethod.php:36)
  at Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
     (/home/imobi239/public_html/vendor/illuminate/container/Util.php:41)
  at Illuminate\Container\Util::unwrapIfClosure()
     (/home/imobi239/public_html/vendor/illuminate/container/BoundMethod.php:93)
  at Illuminate\Container\BoundMethod::callBoundMethod()
     (/home/imobi239/public_html/vendor/illuminate/container/BoundMethod.php:35)
  at Illuminate\Container\BoundMethod::call()
     (/home/imobi239/public_html/vendor/illuminate/container/Container.php:662)
  at Illuminate\Container\Container->call()
     (/home/imobi239/public_html/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:391)
  at Laravel\Lumen\Application->callControllerCallable()
     (/home/imobi239/public_html/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:356)
  at Laravel\Lumen\Application->callLumenController()
     (/home/imobi239/public_html/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:331)
  at Laravel\Lumen\Application->callControllerAction()
     (/home/imobi239/public_html/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:284)
  at Laravel\Lumen\Application->callActionOnArrayBasedRoute()
     (/home/imobi239/public_html/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:269)
  at Laravel\Lumen\Application->handleFoundRoute()
     (/home/imobi239/public_html/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:239)
  at Laravel\Lumen\Application->handleDispatcherResponse()
     (/home/imobi239/public_html/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:174)
  at Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}()
     (/home/imobi239/public_html/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:431)
  at Laravel\Lumen\Application->sendThroughPipeline()
     (/home/imobi239/public_html/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:167)
  at Laravel\Lumen\Application->dispatch()
     (/home/imobi239/public_html/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:112)
  at Laravel\Lumen\Application->run()
     (/home/imobi239/public_html/public/index.php:38)