From 3717817ffef4b8cd756f05c2c552f1c5f488a318 Mon Sep 17 00:00:00 2001 From: Purvesh Date: Tue, 22 Sep 2020 10:30:57 +1200 Subject: [PATCH] Basic hero product module --- .gitignore | 23 +---- LICENSE | 2 +- composer.json | 45 +++++++++ readme.md | 7 ++ register.yml | 5 + resources/lang/en/system.php | 5 + .../views/configuration/heroproduct.blade.php | 13 +++ resources/views/widget/hero-product.blade.php | 32 +++++++ src/Module.php | 61 +++++++++++++ src/Widget/HeroProductWidget.php | 91 +++++++++++++++++++ 10 files changed, 261 insertions(+), 23 deletions(-) create mode 100644 composer.json create mode 100644 readme.md create mode 100644 register.yml create mode 100644 resources/lang/en/system.php create mode 100644 resources/views/configuration/heroproduct.blade.php create mode 100644 resources/views/widget/hero-product.blade.php create mode 100644 src/Module.php create mode 100644 src/Widget/HeroProductWidget.php diff --git a/.gitignore b/.gitignore index 297959a..2752eb9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,2 @@ -/vendor/ node_modules/ -npm-debug.log -yarn-error.log - -# Laravel 4 specific -bootstrap/compiled.php -app/storage/ - -# Laravel 5 & Lumen specific -public/storage -public/hot - -# Laravel 5 & Lumen specific with changed public path -public_html/storage -public_html/hot - -storage/*.key -.env -Homestead.yaml -Homestead.json -/.vagrant -.phpunit.result.cache +.DS_Store diff --git a/LICENSE b/LICENSE index 0d73636..240c026 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Purvesh +Copyright (c) 2018 AvoRed E commerce Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..5f33512 --- /dev/null +++ b/composer.json @@ -0,0 +1,45 @@ +{ + "name" : "avored/heroproduct", + "description" : "AvoRed Laravel E commerce - Hero Product Module", + "keywords" : [ + "framework", + "banner", + "cart", + "laravel", + "e commerce", + "laravel5", + "shop", + "shopping-cart", + "e-commerce", + "shopping cart", + "e commerce" + ], + "license" : "MIT", + "authors" : [{ + "name" : "Purvesh ", + "email" : "ind.purvesh@gmail.com" + } + ], + "type" : "avored-module", + "require" : { + "php": ">7.2", + "avored/module-installer" : "1.*", + "avored/framework" : "~3.1" + }, + "autoload" : { + "classmap" : [ + "database/migrations" + ], + "psr-4" : { + "AvoRed\\HeroProduct\\" : "src/" + } + }, + "homepage" : "https://avored.com", + "support" : { + "email" : "ind.purvesh@gmail.com", + "issues" : "https://avored.com/discussion", + "forum" : "https://avored.com/discussion", + "wiki" : "https://avored.com/docs", + "source" : "https://github.com/avored/banner" + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..1079bc5 --- /dev/null +++ b/readme.md @@ -0,0 +1,7 @@ +# AvoRed Hero Product Module + +### Installation + + composer require avored/heroproduct + +### How to Use diff --git a/register.yml b/register.yml new file mode 100644 index 0000000..cb6cee6 --- /dev/null +++ b/register.yml @@ -0,0 +1,5 @@ +name: AvoRed HeroProduct +identifier: avored-heroproduct +status: active +description: AvoRed HeroProduct Module +namespace: AvoRed\HeroProduct\ diff --git a/resources/lang/en/system.php b/resources/lang/en/system.php new file mode 100644 index 0000000..93e5c01 --- /dev/null +++ b/resources/lang/en/system.php @@ -0,0 +1,5 @@ + 'Hero Product', +]; diff --git a/resources/views/configuration/heroproduct.blade.php b/resources/views/configuration/heroproduct.blade.php new file mode 100644 index 0000000..764d126 --- /dev/null +++ b/resources/views/configuration/heroproduct.blade.php @@ -0,0 +1,13 @@ +@php + $value = $repository->getValueByCode('avored_hero_product'); + + $productRepository = app(\AvoRed\Framework\Database\Contracts\ProductModelInterface::class); + $productOptions = $productRepository->all()->pluck('name', 'id'); + +@endphp + diff --git a/resources/views/widget/hero-product.blade.php b/resources/views/widget/hero-product.blade.php new file mode 100644 index 0000000..d5ebe20 --- /dev/null +++ b/resources/views/widget/hero-product.blade.php @@ -0,0 +1,32 @@ +@if ($heroProduct) +
+
+
+

+ {{ $heroProduct->name }} +

+

+ {{ $heroProduct->description }} +

+
+ {{ session()->get('default_currency')->symbol . number_format($heroProduct->price, 2) }} +
+
+
+ @csrf + + + +
+ + {{-- --}} +
+
+
+ hero +
+
+
+@endif diff --git a/src/Module.php b/src/Module.php new file mode 100644 index 0000000..db7c484 --- /dev/null +++ b/src/Module.php @@ -0,0 +1,61 @@ +registerResources(); + $this->registerTab(); + $this->registerWidget(); + } + + /** + * Register any application services. + * + * @return void + */ + public function register() + { + + } + + /** + * Registering AvoRed HeroProduct Resource + * e.g. Route, View, Database & Translation Path + * + * @return void + */ + protected function registerResources() + { + //$this->loadRoutesFrom(__DIR__ . '/../routes/web.php'); + $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'avored-heroproduct'); + $this->loadViewsFrom(__DIR__ . '/../resources/views', 'avored-heroproduct'); + } + + public function registerTab() + { + Tab::put('system.configuration', function (TabItem $tab) { + $tab->key('system.configuration.hero.product') + ->label('avored-heroproduct::system.config-title') + ->view('avored-heroproduct::configuration.heroproduct'); + }); + } + public function registerWidget() + { + $widget = new HeroProductWidget(); + Widget::make($widget->identifier(), $widget); + } +} diff --git a/src/Widget/HeroProductWidget.php b/src/Widget/HeroProductWidget.php new file mode 100644 index 0000000..430d070 --- /dev/null +++ b/src/Widget/HeroProductWidget.php @@ -0,0 +1,91 @@ +view; + } + + /* + * Widget unique identifier + * + */ + public function identifier() + { + return $this->identifier; + } + + /* + * Widget unique identifier + * + */ + public function label() + { + return $this->label; + } + + /* + * Widget unique identifier + * + */ + public function type() + { + return $this->type; + } + + /** + * View Required Parameters + * + * @return array + */ + public function with() + { + $config = app(ConfigurationModelInterface::class); + $productId = $config->getValueByCode('avored_hero_product'); + + $repository = app(ProductModelInterface::class); + $product = null; + if ($productId > 0) { + $product = $repository->find($productId); + } + return ['heroProduct' => $product]; + } + + public function render() + { + return view($this->view(), $this->with()); + } +}