diff --git a/README.md b/README.md index 70c436f..eef188e 100644 --- a/README.md +++ b/README.md @@ -4,20 +4,21 @@ 1. Web server with PHP version ^8.1 support. 2. PHP extensions: curl, exif, fileinfo, gd, intl, mbstring, mysqli, openssl, pdo_mysql, sodium, xsl - I listed every extensions enabled on my development environment. I don't really know what extensions required for packages the installed :laughing: + I listed every extensions enabled on my development environment. I don't really know what extensions required for the packages installed :laughing: 3. NodeJS version ^14.18.0. 4. Composer version ^2.3.10 ## Project installation -1. Copy `.env.example` file and rename it to `.env`. -2. Create a new database and set the newly created database details inside `.env` file. -2. Run these commands to compile the assets and install the project. +1. Download the release or clone this project inside your web server root folder. Make sure Virtualhost / Server block is configured correctly to point `/public` as document root. +2. Copy `.env.example` file and rename it to `.env`. +3. Create a new database and set the newly created database credentials inside `.env` file. +4. Run these commands to compile the assets and install the project. -`composer compile-project` + `composer compile-project` -`php artisan install PASSWORD USER_NAME EMAIL_ADDRESS` + `php artisan install PASSWORD USER_NAME EMAIL_ADDRESS` ## Copyright diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 7cbc2c3..6960b77 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\Visitor; use Illuminate\Http\Request; class HomeController extends Controller @@ -21,8 +22,15 @@ public function __construct() * * @return \Illuminate\Contracts\Support\Renderable */ - public function index() + public function index(Request $request) { - return view('home'); + if ($request->isMethod('get')) { + $pagination = 5; + + $visitors = Visitor::orderBy('created_at', 'DESC')->paginate($pagination)->withQueryString(); + + return view('home')->with(['visitors' => $visitors]); + } + } } diff --git a/app/Http/Controllers/QRFormsController.php b/app/Http/Controllers/QRFormsController.php deleted file mode 100644 index 3ed0fc1..0000000 --- a/app/Http/Controllers/QRFormsController.php +++ /dev/null @@ -1,33 +0,0 @@ -middleware('auth'); - } - - /** - * Show the application dashboard. - * - * @return \Illuminate\Contracts\Support\Renderable - */ - public function index() - { - return view('qrforms.list'); - } - - public function create() - { - return view('qrforms.add'); - } -} diff --git a/app/Http/Controllers/VisitorController.php b/app/Http/Controllers/VisitorController.php new file mode 100644 index 0000000..ca44b9b --- /dev/null +++ b/app/Http/Controllers/VisitorController.php @@ -0,0 +1,84 @@ +middleware('auth'); + } + + /** + * Show the application dashboard. + * + * @return \Illuminate\Contracts\Support\Renderable + */ + public function index(Request $request, $uuid) + { + if ($request->isMethod('get')) { + // Check if visitor exists. + if (Visitor::where('uuid', $uuid)->first()) { + $visitor = Visitor::where('uuid', $uuid)->first(); + + return view('visitors.view')->with(['visitor' => $visitor]); + } else { + return abort(404); + } + } + } + + public function create(Request $request) + { + + if ($request->isMethod('post')) { + + $validated = $request->validate([ + 'visitor-name' => ['required'], + 'visitor-ic-number' => ['required'], + 'visitor-vehicle-plate-number' => ['required'], + 'visitor-datetime' => ['required'], + ]); + + $uuid = (string) Str::uuid(); + $name = $request->input('visitor-name'); + $icNumber = $request->input('visitor-ic-number'); + $plateNumber = $request->input('visitor-vehicle-plate-number'); + $accessDateTime = $request->input('visitor-datetime'); + $userName = Auth::user()->name; + + $visitor = Visitor::create([ + 'uuid' => $uuid, + 'name' => $name, + 'ic_number' => $icNumber, + 'vehicle_plate_number' => $plateNumber, + 'visit_datetime' => $accessDateTime, + 'added_by' => $userName, + ]); + + $request->session()->flash('addVisitorSuccess', 'Visitor successfully added!'); + + // Reference: https://startutorial.com/view/php-qr-code-generator-with-source-code + $qrCode = (new QRCode())->render('visitorqr: ' . $uuid); + $request->session()->flash('qrCode', $qrCode); + $request->session()->flash('uuid', $uuid); + + return back(); + } + + if ($request->isMethod('get')) { + return view('visitors.add'); + } + } +} diff --git a/app/Models/Visitor.php b/app/Models/Visitor.php new file mode 100644 index 0000000..9a74280 --- /dev/null +++ b/app/Models/Visitor.php @@ -0,0 +1,63 @@ +render('visitorqr: ' . $this->uuid); + } + + /** + * Generate QR based on UUIDs + * + */ + public function getDateTimeAttribute() { + return new DateTime($this->visit_datetime); + } + + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = [ + 'uuid', + 'name', + 'ic_number', + 'vehicle_plate_number', + 'visit_datetime', + 'added_by', + ]; + + /** + * The attributes that should be hidden for serialization. + * + * @var array + */ + protected $hidden = []; + + /** + * The attributes that should be cast. + * + * @var array + */ + protected $casts = []; +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index ee8ca5b..35cbe0f 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use Illuminate\Pagination\Paginator; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -23,6 +24,6 @@ public function register() */ public function boot() { - // + Paginator::useBootstrapFive(); } } diff --git a/composer.json b/composer.json index 06020ab..5df3330 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,9 @@ "license": "MIT", "require": { "php": "^8.0.2", + "blade-ui-kit/blade-ui-kit": "^0.3.4", + "chillerlan/php-qrcode": "^4.3", + "doctrine/dbal": "^3.5", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^9.19", "laravel/sanctum": "^3.0", diff --git a/composer.lock b/composer.lock index f9179af..2923249 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,88 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "95b694b18e97667437a84c0f7c711826", + "content-hash": "d7997ad488bb6b3632e3213b91ffb78d", "packages": [ + { + "name": "blade-ui-kit/blade-ui-kit", + "version": "0.3.4", + "source": { + "type": "git", + "url": "https://github.com/blade-ui-kit/blade-ui-kit.git", + "reference": "139f387d219bceb647c02d18c6b74cebb4c8dae6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/blade-ui-kit/blade-ui-kit/zipball/139f387d219bceb647c02d18c6b74cebb4c8dae6", + "reference": "139f387d219bceb647c02d18c6b74cebb4c8dae6", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/filesystem": "^7.0|^8.0|^9.0", + "illuminate/support": "^7.0|^8.0|^9.0", + "illuminate/view": "^7.0|^8.0|^9.0", + "nesbot/carbon": "^2.38", + "php": "^7.3|^8.0" + }, + "require-dev": { + "gajus/dindent": "^2.0", + "guzzlehttp/guzzle": "^7.4", + "league/commonmark": "^1.4|^2.0", + "lorisleiva/cron-translator": "^0.1.1", + "orchestra/testbench": "^5.0|^6.0|^7.1", + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "league/commonmark": "Required to use the markdown component (^1.4).", + "lorisleiva/cron-translator": "Required to use the cron component (^0.1.1)." + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "BladeUIKit\\BladeUIKitServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "BladeUIKit\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dries Vints", + "homepage": "https://driesvints.com" + } + ], + "description": "A set of renderless components to utilise in your Laravel Blade views.", + "homepage": "https://github.com/blade-ui-kit/blade-ui-kit", + "keywords": [ + "blade", + "laravel", + "ui" + ], + "support": { + "issues": "https://github.com/blade-ui-kit/blade-ui-kit/issues", + "source": "https://github.com/blade-ui-kit/blade-ui-kit" + }, + "funding": [ + { + "url": "https://github.com/caneco", + "type": "github" + }, + { + "url": "https://github.com/driesvints", + "type": "github" + } + ], + "time": "2022-04-17T13:03:05+00:00" + }, { "name": "brick/math", "version": "0.10.2", @@ -62,6 +142,148 @@ ], "time": "2022-08-10T22:54:19+00:00" }, + { + "name": "chillerlan/php-qrcode", + "version": "4.3.4", + "source": { + "type": "git", + "url": "https://github.com/chillerlan/php-qrcode.git", + "reference": "2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/chillerlan/php-qrcode/zipball/2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d", + "reference": "2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d", + "shasum": "" + }, + "require": { + "chillerlan/php-settings-container": "^2.1.4", + "ext-mbstring": "*", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phan/phan": "^5.3", + "phpunit/phpunit": "^9.5", + "setasign/fpdf": "^1.8.2" + }, + "suggest": { + "chillerlan/php-authenticator": "Yet another Google authenticator! Also creates URIs for mobile apps.", + "setasign/fpdf": "Required to use the QR FPDF output." + }, + "type": "library", + "autoload": { + "psr-4": { + "chillerlan\\QRCode\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kazuhiko Arase", + "homepage": "https://github.com/kazuhikoarase" + }, + { + "name": "Smiley", + "email": "smiley@chillerlan.net", + "homepage": "https://github.com/codemasher" + }, + { + "name": "Contributors", + "homepage": "https://github.com/chillerlan/php-qrcode/graphs/contributors" + } + ], + "description": "A QR code generator. PHP 7.4+", + "homepage": "https://github.com/chillerlan/php-qrcode", + "keywords": [ + "phpqrcode", + "qr", + "qr code", + "qrcode", + "qrcode-generator" + ], + "support": { + "issues": "https://github.com/chillerlan/php-qrcode/issues", + "source": "https://github.com/chillerlan/php-qrcode/tree/4.3.4" + }, + "funding": [ + { + "url": "https://www.paypal.com/donate?hosted_button_id=WLYUNAT9ZTJZ4", + "type": "custom" + }, + { + "url": "https://ko-fi.com/codemasher", + "type": "ko_fi" + } + ], + "time": "2022-07-25T09:12:45+00:00" + }, + { + "name": "chillerlan/php-settings-container", + "version": "2.1.4", + "source": { + "type": "git", + "url": "https://github.com/chillerlan/php-settings-container.git", + "reference": "1beb7df3c14346d4344b0b2e12f6f9a74feabd4a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/chillerlan/php-settings-container/zipball/1beb7df3c14346d4344b0b2e12f6f9a74feabd4a", + "reference": "1beb7df3c14346d4344b0b2e12f6f9a74feabd4a", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phan/phan": "^5.3", + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "chillerlan\\Settings\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Smiley", + "email": "smiley@chillerlan.net", + "homepage": "https://github.com/codemasher" + } + ], + "description": "A container class for immutable settings objects. Not a DI container. PHP 7.4+", + "homepage": "https://github.com/chillerlan/php-settings-container", + "keywords": [ + "PHP7", + "Settings", + "configuration", + "container", + "helper" + ], + "support": { + "issues": "https://github.com/chillerlan/php-settings-container/issues", + "source": "https://github.com/chillerlan/php-settings-container" + }, + "funding": [ + { + "url": "https://www.paypal.com/donate?hosted_button_id=WLYUNAT9ZTJZ4", + "type": "custom" + }, + { + "url": "https://ko-fi.com/codemasher", + "type": "ko_fi" + } + ], + "time": "2022-07-05T22:32:14+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.2", @@ -137,6 +359,344 @@ }, "time": "2022-10-27T11:44:00+00:00" }, + { + "name": "doctrine/cache", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "1ca8f21980e770095a31456042471a57bc4c68fb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/1ca8f21980e770095a31456042471a57bc4c68fb", + "reference": "1ca8f21980e770095a31456042471a57bc4c68fb", + "shasum": "" + }, + "require": { + "php": "~7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "cache/integration-tests": "dev-master", + "doctrine/coding-standard": "^9", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "psr/cache": "^1.0 || ^2.0 || ^3.0", + "symfony/cache": "^4.4 || ^5.4 || ^6", + "symfony/var-exporter": "^4.4 || ^5.4 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", + "keywords": [ + "abstraction", + "apcu", + "cache", + "caching", + "couchdb", + "memcached", + "php", + "redis", + "xcache" + ], + "support": { + "issues": "https://github.com/doctrine/cache/issues", + "source": "https://github.com/doctrine/cache/tree/2.2.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", + "type": "tidelift" + } + ], + "time": "2022-05-20T20:07:39+00:00" + }, + { + "name": "doctrine/dbal", + "version": "3.5.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "f38ee8aaca2d58ee88653cb34a6a3880c23f38a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/f38ee8aaca2d58ee88653cb34a6a3880c23f38a5", + "reference": "f38ee8aaca2d58ee88653cb34a6a3880c23f38a5", + "shasum": "" + }, + "require": { + "composer-runtime-api": "^2", + "doctrine/cache": "^1.11|^2.0", + "doctrine/deprecations": "^0.5.3|^1", + "doctrine/event-manager": "^1|^2", + "php": "^7.4 || ^8.0", + "psr/cache": "^1|^2|^3", + "psr/log": "^1|^2|^3" + }, + "require-dev": { + "doctrine/coding-standard": "10.0.0", + "jetbrains/phpstorm-stubs": "2022.2", + "phpstan/phpstan": "1.8.10", + "phpstan/phpstan-strict-rules": "^1.4", + "phpunit/phpunit": "9.5.25", + "psalm/plugin-phpunit": "0.17.0", + "squizlabs/php_codesniffer": "3.7.1", + "symfony/cache": "^5.4|^6.0", + "symfony/console": "^4.4|^5.4|^6.0", + "vimeo/psalm": "4.29.0" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\DBAL\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", + "homepage": "https://www.doctrine-project.org/projects/dbal.html", + "keywords": [ + "abstraction", + "database", + "db2", + "dbal", + "mariadb", + "mssql", + "mysql", + "oci8", + "oracle", + "pdo", + "pgsql", + "postgresql", + "queryobject", + "sasql", + "sql", + "sqlite", + "sqlserver", + "sqlsrv" + ], + "support": { + "issues": "https://github.com/doctrine/dbal/issues", + "source": "https://github.com/doctrine/dbal/tree/3.5.1" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", + "type": "tidelift" + } + ], + "time": "2022-10-24T07:26:18+00:00" + }, + { + "name": "doctrine/deprecations", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "reference": "0e2a4f1f8cdfc7a92ec3b01c9334898c806b30de", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9", + "phpunit/phpunit": "^7.5|^8.5|^9.5", + "psr/log": "^1|^2|^3" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/v1.0.0" + }, + "time": "2022-05-02T15:47:09+00:00" + }, + { + "name": "doctrine/event-manager", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/event-manager.git", + "reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/750671534e0241a7c50ea5b43f67e23eb5c96f32", + "reference": "750671534e0241a7c50ea5b43f67e23eb5c96f32", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "conflict": { + "doctrine/common": "<2.9" + }, + "require-dev": { + "doctrine/coding-standard": "^10", + "phpstan/phpstan": "^1.8.8", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^4.28" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/event-manager.html", + "keywords": [ + "event", + "event dispatcher", + "event manager", + "event system", + "events" + ], + "support": { + "issues": "https://github.com/doctrine/event-manager/issues", + "source": "https://github.com/doctrine/event-manager/tree/2.0.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager", + "type": "tidelift" + } + ], + "time": "2022-10-12T20:59:15+00:00" + }, { "name": "doctrine/inflector", "version": "2.0.6", @@ -2240,6 +2800,55 @@ ], "time": "2022-07-30T15:51:26+00:00" }, + { + "name": "psr/cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/3.0.0" + }, + "time": "2021-02-03T23:26:27+00:00" + }, { "name": "psr/container", "version": "2.0.2", diff --git a/database/migrations/2022_11_15_222448_create_visitors_table.php b/database/migrations/2022_11_15_222448_create_visitors_table.php new file mode 100644 index 0000000..fc2dff4 --- /dev/null +++ b/database/migrations/2022_11_15_222448_create_visitors_table.php @@ -0,0 +1,37 @@ +id(); + $table->string('uuid', 50); + $table->string('name', 255); + $table->string('ic_number', 20); + $table->string('vehicle_plate_number', 20); + $table->dateTime('visit_datetime'); + $table->string('added_by', 255); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('visitors'); + } +}; diff --git a/database/migrations/2022_11_16_162102_drop_uuid_column_from_visitors_table.php b/database/migrations/2022_11_16_162102_drop_uuid_column_from_visitors_table.php new file mode 100644 index 0000000..c25bff8 --- /dev/null +++ b/database/migrations/2022_11_16_162102_drop_uuid_column_from_visitors_table.php @@ -0,0 +1,32 @@ +dropColumn('uuid'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('visitors', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2022_11_16_162205_add_uuid_column_as_primary_key_on_visitors_table.php b/database/migrations/2022_11_16_162205_add_uuid_column_as_primary_key_on_visitors_table.php new file mode 100644 index 0000000..bab4af6 --- /dev/null +++ b/database/migrations/2022_11_16_162205_add_uuid_column_as_primary_key_on_visitors_table.php @@ -0,0 +1,35 @@ +dropPrimary(); + $table->unsignedInteger('id')->change(); + $table->dropColumn('id'); + $table->uuid()->primary()->unique()->index()->first(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('visitors', function (Blueprint $table) { + // + }); + } +}; diff --git a/resources/js/scanner.js b/resources/js/scanner.js index b456193..8baaac0 100644 --- a/resources/js/scanner.js +++ b/resources/js/scanner.js @@ -4,7 +4,7 @@ function onScanSuccess(decodedText, decodedResult) { // Parsing decoded text // It must starts with formqr-code - if (decodedText.split(": ")[0] != "formqr-code") { + if (decodedText.split(": ")[0] != "visitorqr") { document.getElementById("qr-error").removeAttribute("hidden"); setTimeout(() => { @@ -14,7 +14,7 @@ function onScanSuccess(decodedText, decodedResult) { let parsedUID = decodedText.split(": ")[1]; // Redirect to QR code data page - window.location.href = "/qrcodes/" + parsedUID; + window.location.href = "/visitors/view/" + parsedUID; } } diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index b48bd7e..2b2356b 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -5,54 +5,57 @@
-
{{ __('QR Code List') }}
+
{{ __('Visitor List') }}
- - - - - - - - - - - - - - @for ($i = 0; $i < 10; $i++) + @if ($visitors->count() > 0) + - - - {{-- Temporary UID placeholder --}} - - {{-- Temporary QR Form UID placeholder --}} - - - - - + + + + + + + - @endfor - + + + @foreach ($visitors as $visitor) + + + + + + + + + + @endforeach + + @else +

No visitors added.

+ @endif
{{ __('No') }}{{ __('QR Code') }}{{ __('UID') }}{{ __('QR Form UID') }}{{ __('Added On') }}{{ __('View') }}{{ __('Update') }}{{ __('Delete') }}
{{ $i + 1 }} - - - {{ Str::limit(Str::random(30), 15) }} - - {{ Str::limit(Str::random(30), 15) }} - -

XX/XX/XXXX XX:XX XX

-
- - - - - - {{ __('QR Code') }}{{ __('UUID') }}{{ __('Name') }}{{ __('Access Date & Time') }}{{ __('View') }}{{ __('Update') }}{{ __('Delete') }}
+ + {{ $visitor->uuid }} + + +

{{ $visitor->uuid }}

+
+

{{ $visitor->name }}

+
+ + + + + + + +
+ {{ $visitors->links() }}
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 782eaf5..53c7c62 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -17,6 +17,7 @@ @vite(['resources/sass/app.scss', 'resources/js/app.js']) + @bukStyles(true)
@@ -50,15 +51,12 @@ {{ __('Home') }} - - + @if (Route::has('register')) @@ -98,5 +96,6 @@ {{ config('app.name', 'visitorqr') }} {{ env('APP_VERSION', 'v0.1.0-beta') }}

Copyright © Hanis Irfan {{ env('COPYRIGHT_YEAR', '2022') }}

+ @bukScripts(true) diff --git a/resources/views/qrforms/add.blade.php b/resources/views/qrforms/add.blade.php deleted file mode 100644 index e44801a..0000000 --- a/resources/views/qrforms/add.blade.php +++ /dev/null @@ -1,108 +0,0 @@ -@extends('layouts.app') - -@section('content') -
-
-
-
-
{{ __('QR Form Add') }}
-
-
-
- - -
-
- {{-- Field groups --}} - - -
-
- -
- -
-
- -
-
- -
-
-
-
-
- - -
-
- - - {{-- Fields start here --}} -
-
-

Name: Test Field

-

Type: Text

-
-
- -
-
- -
-
- -
-
-
-
-

Name: Test Field

-

Type: Text

-
-
- -
-
- -
-
- -
-
-
-
-
-
-
- - {{-- Submit btn --}} - -
-
-
-
-
-
-@endsection diff --git a/resources/views/qrforms/list.blade.php b/resources/views/qrforms/list.blade.php deleted file mode 100644 index 0614073..0000000 --- a/resources/views/qrforms/list.blade.php +++ /dev/null @@ -1,53 +0,0 @@ -@extends('layouts.app') - -@section('content') -
-
-
-
-
{{ __('QR Form List') }}
- -
-
- - - - - - - - - - - - - @for ($i = 0; $i < 10; $i++) - - - {{-- Temporary UID placeholder --}} - - - - - - - @endfor - -
{{ __('No') }}{{ __('UID') }}{{ __('Added On') }}{{ __('View') }}{{ __('Update') }}{{ __('Delete') }}
{{ $i + 1 }} - {{ Str::limit(Str::random(30), 15) }} - -

XX/XX/XXXX XX:XX XX

-
- - - - - -
-
-
-
-
-
-
-@endsection diff --git a/resources/views/visitors/add.blade.php b/resources/views/visitors/add.blade.php new file mode 100644 index 0000000..eb4faf2 --- /dev/null +++ b/resources/views/visitors/add.blade.php @@ -0,0 +1,72 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Add Visitor') }}
+
+ @if(session()->has('addVisitorSuccess')) + +
+

{{ session('addVisitorSuccess') }}

+
+ + {{ session('uuid') }} + +

{{ __('Click on the QR code to download it.') }}

+
+
+
+ @endif +
+ @csrf +
+ + +
+ @error('visitor-name') +
+ {{ __('Visitor name is required!') }} +
+ @enderror + +
+ + +
+ @error('visitor-ic-number') +
+ {{ __('Visitor IC number is required!') }} +
+ @enderror + +
+ + +
+ @error('visitor-vehicle-plate-number') +
+ {{ __('Visitor vehicle plate number is required!') }} +
+ @enderror + +
+ + +
+ @error('visitor-datetime') +
+ {{ __('Visit date & time is required!') }} +
+ @enderror + + +
+
+
+
+
+
+@endsection diff --git a/resources/views/visitors/view.blade.php b/resources/views/visitors/view.blade.php new file mode 100644 index 0000000..44f2f30 --- /dev/null +++ b/resources/views/visitors/view.blade.php @@ -0,0 +1,40 @@ +@extends('layouts.app') + +@section('content') +
+
+
+
+
{{ __('Visitor Details') }}
+
+ {{-- @if(session()->has('addVisitorSuccess')) + +
+

{{ session('addVisitorSuccess') }}

+
+ + {{ session('uuid') }} + +

{{ __('Click on the QR code to download it.') }}

+
+
+
+ @endif --}} +
+ {{ __('Name') }} : {{ $visitor->name }} +
+
+ {{ __('IC Number') }} : {{ $visitor->ic_number }} +
+
+ {{ __('Vehicle Plate Number') }} : {{ $visitor->vehicle_plate_number }} +
+
+ {{ __('Visit Date & Time') }} : +
+
+
+
+
+
+@endsection diff --git a/routes/web.php b/routes/web.php index bb50649..97d4cd3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,8 +2,8 @@ use Illuminate\Support\Facades\Route; use App\Http\Controllers\HomeController; -use App\Http\Controllers\QRFormsController; use App\Http\Controllers\ScannerController; +use App\Http\Controllers\VisitorController; /* |-------------------------------------------------------------------------- @@ -24,7 +24,8 @@ Route::get('/home', [HomeController::class, 'index'])->name('home'); -Route::get('/qrforms', [QRFormsController::class, 'index'])->name('qrforms'); -Route::get('/qrforms/add', [QRFormsController::class, 'create'])->name('qrforms.add'); +Route::get('/visitors/view/{uuid}', [VisitorController::class, 'index'])->name('visitors.view'); +Route::get('/visitors/add', [VisitorController::class, 'create'])->name('visitors.add'); +Route::post('/visitors/add', [VisitorController::class, 'create']); Route::get('/scanner', [ScannerController::class, 'index'])->name('scanner');