From 53b054cf022cfc8e24152e397e9a3e38c5f730e0 Mon Sep 17 00:00:00 2001
From: Ben Rutland <benrutland@hotmail.com>
Date: Wed, 13 Oct 2021 22:53:54 +0100
Subject: [PATCH] updated php version, helpers and aliases

---
 composer.json |  2 +-
 functions.php |  5 +++-
 helpers.php   | 65 +++++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/composer.json b/composer.json
index 4d87ee6..cfebe43 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,7 @@
     ]
   },
   "require": {
-    "php": "^7.3",
+    "php": "^7.4|^8.0",
     "radiate/framework": "^2.0"
   },
   "scripts": {
diff --git a/functions.php b/functions.php
index f282c77..d048620 100644
--- a/functions.php
+++ b/functions.php
@@ -101,14 +101,17 @@
     'Cache'      => \Radiate\Support\Facades\Cache::class,
     'Collection' => \Radiate\Support\Collection::class,
     'Config'     => \Radiate\Support\Facades\Config::class,
+    'Crypt'      => \Radiate\Support\Facades\Crypt::class,
     'DB'         => \Radiate\Support\Facades\DB::class,
     'Event'      => \Radiate\Support\Facades\Event::class,
     'File'       => \Radiate\Support\Facades\File::class,
-    'Hash'       => \Radiate\Support\Hash::class,
+    'Gate'       => \Radiate\Support\Facades\Gate::class,
+    'Hash'       => \Radiate\Support\Facades\Hash::class,
     'Http'       => \Radiate\Support\Facades\Http::class,
     'Mail'       => \Radiate\Support\Facades\Mail::class,
     'Option'     => \Radiate\Support\Facades\Option::class,
     'Request'    => \Radiate\Support\Facades\Request::class,
+    'Response'   => \Radiate\Support\Facades\Response::class,
     'Route'      => \Radiate\Support\Facades\Route::class,
     'Str'        => \Radiate\Support\Str::class,
     'URL'        => \Radiate\Support\Facades\URL::class,
diff --git a/helpers.php b/helpers.php
index 6c98e3b..c5e4b59 100644
--- a/helpers.php
+++ b/helpers.php
@@ -1,6 +1,26 @@
 <?php
 
-use Radiate\Support\Facades\App;
+use Radiate\Foundation\Application;
+use Radiate\Http\ResponseFactory;
+use Radiate\View\Factory as ViewFactory;
+
+if (!function_exists('app')) {
+    /**
+     * Get the available container instance.
+     *
+     * @param  string|null  $abstract
+     * @param  array  $parameters
+     * @return mixed|\Radiate\Foundation\Application
+     */
+    function app(?string $abstract = null, array $parameters = [])
+    {
+        if (is_null($abstract)) {
+            return Application::getInstance();
+        }
+
+        return Application::getInstance()->make($abstract, $parameters);
+    }
+}
 
 if (!function_exists('base_path')) {
     /**
@@ -11,7 +31,7 @@
      */
     function base_path(?string $path = null)
     {
-        return App::basePath($path);
+        return app()->basePath($path);
     }
 }
 
@@ -36,3 +56,44 @@ function env(string $key, $default = null)
         return $default;
     }
 }
+
+if (!function_exists('response')) {
+    /**
+     * Create a HTTP response
+     *
+     * @param mixed $content
+     * @param integer $status
+     * @param array $headers
+     * @return \Radiate\Http\ResponseFactory|\Radiate\Http\Response
+     */
+    function response($content = '', int $status = 200, array $headers = [])
+    {
+        $factory = app(ResponseFactory::class);
+
+        if (func_num_args() === 0) {
+            return $factory;
+        }
+
+        return $factory->make($content, $status, $headers);
+    }
+}
+
+if (!function_exists('view')) {
+    /**
+     * Create a view
+     *
+     * @param string|null $view
+     * @param array $data
+     * @return \Radiate\View\Factory|\Radiate\View\View
+     */
+    function view(?string $view = null, array $data = [])
+    {
+        $factory = app(ViewFactory::class);
+
+        if (func_num_args() === 0) {
+            return $factory;
+        }
+
+        return $factory->make($view, $data);
+    }
+}