-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b93c39c
commit 3717817
Showing
10 changed files
with
261 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" : "[email protected]" | ||
} | ||
], | ||
"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" : "[email protected]", | ||
"issues" : "https://avored.com/discussion", | ||
"forum" : "https://avored.com/discussion", | ||
"wiki" : "https://avored.com/docs", | ||
"source" : "https://github.com/avored/banner" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# AvoRed Hero Product Module | ||
|
||
### Installation | ||
|
||
composer require avored/heroproduct | ||
|
||
### How to Use |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: AvoRed HeroProduct | ||
identifier: avored-heroproduct | ||
status: active | ||
description: AvoRed HeroProduct Module | ||
namespace: AvoRed\HeroProduct\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return [ | ||
'config-title' => 'Hero Product', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
<avored-select | ||
field-name="avored_hero_product" | ||
label-text="{{ __('avored-heroproduct::system.config-title') }}" | ||
:options="{{ json_encode($productOptions) }}" | ||
init-value="{{ $value }}" | ||
></avored-select> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@if ($heroProduct) | ||
<section class="text-gray-700 body-font"> | ||
<div class="container mx-auto flex px-5 py-24 md:flex-row flex-col items-center"> | ||
<div class="lg:flex-grow md:w-1/2 lg:pr-24 md:pr-16 flex flex-col md:items-start md:text-left mb-16 md:mb-0 items-center text-center"> | ||
<h1 class="title-font text-re sm:text-4xl text-3xl mb-4 font-medium text-gray-700"> | ||
{{ $heroProduct->name }} | ||
</h1> | ||
<p class="leading-relaxed"> | ||
{{ $heroProduct->description }} | ||
</p> | ||
<div class="text-2xl text-red-700 font-semibold my-4"> | ||
{{ session()->get('default_currency')->symbol . number_format($heroProduct->price, 2) }} | ||
</div> | ||
<div class="flex justify-center"> | ||
<form method="post" action="{{ route('add.to.cart') }}"> | ||
@csrf | ||
<input type="hidden" name="slug" value="{{ $heroProduct->slug }}" /> | ||
<input type="hidden" name="qty" value="1" /> | ||
<button type="submit" class="px-6 py-3 bg-red-500 text-white font-semibold rounded"> | ||
Add to cart | ||
</button> | ||
</form> | ||
|
||
{{-- <button class="ml-4 inline-flex text-gray-700 bg-gray-200 border-0 py-2 px-6 focus:outline-none hover:bg-gray-300 rounded text-lg">Button</button> --}} | ||
</div> | ||
</div> | ||
<div class="lg:max-w-lg lg:w-full md:w-1/2 w-5/6"> | ||
<img class="object-cover object-center rounded" alt="hero" src="{{ $heroProduct->mainImage->path ?? 'https://placehold.it/250x250' }}"> | ||
</div> | ||
</div> | ||
</section> | ||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
namespace AvoRed\HeroProduct; | ||
|
||
use AvoRed\Framework\Support\Facades\Tab; | ||
use AvoRed\Framework\Support\Facades\Widget; | ||
use AvoRed\Framework\Tab\TabItem; | ||
use AvoRed\HeroProduct\Widget\HeroProductWidget; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class Module extends ServiceProvider | ||
{ | ||
|
||
/** | ||
* Bootstrap any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
namespace AvoRed\HeroProduct\Widget; | ||
|
||
use AvoRed\Framework\Database\Contracts\ConfigurationModelInterface; | ||
use AvoRed\Framework\Database\Contracts\OrderModelInterface; | ||
use AvoRed\Framework\Database\Contracts\ProductModelInterface; | ||
|
||
class HeroProductWidget | ||
{ | ||
/** | ||
* Widget View Path | ||
* @var string $view | ||
*/ | ||
|
||
protected $view = "avored-heroproduct::widget.hero-product"; | ||
|
||
/** | ||
* Widget Label | ||
* @var string $view | ||
*/ | ||
|
||
protected $label = 'Hero Product'; | ||
|
||
/** | ||
* Widget Type | ||
* @var string $view | ||
*/ | ||
|
||
protected $type = "cms"; | ||
|
||
/** | ||
* Widget unique identifier | ||
* @var string $identifier | ||
*/ | ||
protected $identifier = "avored-hero-product"; | ||
|
||
public function view() | ||
{ | ||
return $this->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()); | ||
} | ||
} |