340 'name' => $product_arr['translator_name'],
341 'content' => $product_arr['translator_content'],
345 'total' => $product_arr['rating_total'],
346 'avg' => $product_arr['rating_avg'],
347 'id' => $product_arr['rating_id'],
348 'score' => $product_arr['rating_score'],
351 $product->versions = collect([(new ProductVersion)->load(['title' => $product_arr['version_title'], 'content' => $product_arr['version_content']])->decode()]);
352 $product->platforms = collect(explode(', ', $product_arr['other_platforms']))->filter(fn ($platform) => $platform != $product_arr['platform'])->unique()->all();
356 if ($version !== null && !empty(trim($version))) {
357 foreach ($product->versions()->all() as $ver) {
358 if (Str::slugIf($ver->title ?? '') == $version) {
364 $version = $product->versions()->first();
340 'name' => $product_arr['translator_name'],
341 'content' => $product_arr['translator_content'],
345 'total' => $product_arr['rating_total'],
346 'avg' => $product_arr['rating_avg'],
347 'id' => $product_arr['rating_id'],
348 'score' => $product_arr['rating_score'],
351 $product->versions = collect([(new ProductVersion)->load(['title' => $product_arr['version_title'], 'content' => $product_arr['version_content']])->decode()]);
352 $product->platforms = collect(explode(', ', $product_arr['other_platforms']))->filter(fn ($platform) => $platform != $product_arr['platform'])->unique()->all();
356 if ($version !== null && !empty(trim($version))) {
357 foreach ($product->versions()->all() as $ver) {
358 if (Str::slugIf($ver->title ?? '') == $version) {
364 $version = $product->versions()->first();
44 return array_values($inputs);
47 protected function loadClass($callback, array $params = [])
49 if (is_array($callback) && !method_exists($callback[0], $callback[1])) {
50 throw new Exception('Method: ' . $callback[1] . ' does not exists in Class: ' . get_class($callback[0]));
53 return call_user_func($callback, ...$params);
56 protected function createClass(string $class, ...$args)
58 return new $class(...$args);
55 } elseif ($method === 'post') {
56 $callback[1] = 'store';
57 } elseif ($method === 'get' && isset($params[$action])) {
58 $callback[1] = 'show';
60 $callback[1] = 'index';
65 request()->setRoute($route);
67 return $this->loadClass($callback, $this->reflectParamiters($this->excapeParamiters($route->getParameters()), (is_array($callback) ? [$callback[0]::class, $callback[1]] : $callback)));
70 protected function callMiddlewares($middlewares): void
72 foreach ((array) $middlewares as $middleware) {
74 $class = $this->createClass($middleware);
76 if (!$class instanceof IMiddleware) {
77 throw new MiddlewareException($middleware . ' must be implement interface: ' . IMiddleware::class);
80 $this->loadClass([$class, 'handle'], $this->reflectParamiters([], [$middleware, 'handle']));
49 // call route middlewares
50 $this->callMiddlewares($route->getMiddlewares());
52 // utilize method required paramiters
53 $params = $this->utilizeRouteParam($matches, $route);
55 // set router paramiters
56 if (!empty($params)) {
57 $route->parameters($this->reflectParamiters($params, $route->getCallback()));
60 // dispatch route callback
61 return $this->dispatchRoute($route);
65 // not found any route for this path
66 // throw new NotFoundException('the route does not matched..');
70 public function route(string $name, $params = null): IRoute
72 foreach ($this->getRoutes() as $single_route) {
73 if (in_array($name, (array) $single_route->getName())) {
129 $this->triggerEvent(self::EVENT['created']);
132 public function run(): void
134 // Before Application Start Event
135 $this->triggerEvent(self::EVENT['beforeMount']);
137 // Start Application Route
138 echo $this->router->resolve();
140 // After Application Start Event
141 $this->triggerEvent(self::EVENT['mounted']);
144 public function getAuth(): Auth
146 if (!isset($this->auth)) {
147 $this->auth = new Auth;
29 // <div style="background:#000;color:#fff;padding:10px 20px;">
30 // <h3 style="font-size:25px;font-style: italic;color:blue;"></h3>
31 // <div style="border-bottom:1px solid rgba(255,255,255,0.25);padding:10px;margin-bottom:15px;">App Execution Has Started: {$started}</div>
32 // <div style="border-bottom:1px solid rgba(255,255,255,0.25);padding:10px;margin-bottom:15px;">App Execution Has End: {$end}</div>
33 // <div style="border-bottom:1px solid rgba(255,255,255,0.25);padding:10px;margin-bottom:15px;">App Total Execution: {$total}</div>
38 // run the application