Skip to content

Commit

Permalink
Merge pull request #173 from avored/dev
Browse files Browse the repository at this point in the history
merging dev to master
  • Loading branch information
indpurvesh authored Jun 30, 2018
2 parents c1cb264 + 6833e3a commit ade803b
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 91 deletions.
42 changes: 18 additions & 24 deletions app/Http/Controllers/ProductViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Http\Controllers;

use AvoRed\Framework\Models\Database\Product;
use AvoRed\Framework\Models\Contracts\ProductInterface;
use Illuminate\Http\Request;
use AvoRed\Framework\Models\Contracts\ProductDownloadableUrlInterface;
Expand All @@ -15,50 +14,45 @@ class ProductViewController extends Controller
*/
protected $repository;

/**
* Product Downloadable Url Repository
* @var \AvoRed\Framework\Models\Repository\ProductDownloadableUrlRepository
*/
/**
* Product Downloadable Url Repository
* @var \AvoRed\Framework\Models\Repository\ProductDownloadableUrlRepository
*/
protected $downRep;

public function __construct(ProductInterface $repository , ProductDownloadableUrlInterface $downRep)
{
$this->repository = $repository;
$this->downRep = $downRep;
public function __construct(
ProductInterface $repository,
ProductDownloadableUrlInterface $downRep
) {
$this->repository = $repository;
$this->downRep = $downRep;
}

public function view($slug)
{
$product = $this->repository->findBySlug($slug);
$title = (!empty($product->meta_title)) ?
$product->meta_title :
$product->name;

$description = (!empty($product->meta_description)) ?
$product->meta_description :
substr($product->description, 0, 255);
$title = $product->meta_title ?? $product->name;
$description = $product->meta_description ?? substr($product->description, 0, 255);

return view('product.view')
->with('product', $product)
->with('title', $title)
->with('description', $description);
}

public function downloadDemoProduct(Request $request) {

$downModel = $this->downRep->findByToken($request->get('product_token'));
public function downloadDemoProduct(Request $request)
{
$downModel = $this->downRep->findByToken($request->get('product_token'));

$path = storage_path('app/public' . DIRECTORY_SEPARATOR . $downModel->demo_path);
return response()->download($path);

}

public function downloadMainProduct(Request $request) {

$downModel = $this->downRep->findByToken($request->get('product_token'));
public function downloadMainProduct(Request $request)
{
$downModel = $this->downRep->findByToken($request->get('product_token'));

$path = storage_path('app/public' . DIRECTORY_SEPARATOR . $downModel->main_path);
return response()->download($path);

}
}
26 changes: 2 additions & 24 deletions app/Http/Controllers/User/MyAccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use AvoRed\Framework\Image\Facade as Image;
use Illuminate\Support\Facades\File;
use App\Http\Controllers\Controller;

class MyAccountController extends Controller
Expand Down Expand Up @@ -65,16 +64,9 @@ public function uploadImagePost(UploadUserImageRequest $request)
$user->image_path->destroy();
}

$relativePath = 'uploads/users/' . $user->id;
$path = $relativePath;
$image = Image::upload($image, 'uploads/users/' . $user->id);

$dbPath = $relativePath . DIRECTORY_SEPARATOR . $image->getClientOriginalName();

$this->directory(public_path($relativePath));

Image::upload($image, $path);

$user->update(['image_path' => $dbPath]);
$user->update(['image_path' => $image->relativePath]);

return redirect()->route('my-account.home')
->with('notificationText', 'User Profile Image Uploaded successfully!!');
Expand All @@ -85,20 +77,6 @@ public function changePassword()
return view('user.my-account.change-password');
}

/**
* Create Directories if not exists
*
* @var string $path
* @return \AvoRed\Framework\Image\Service
*/
public function directory($path)
{
if (!File::exists($path)) {
File::makeDirectory($path, 0775, true, true);
}
return $this;
}

public function changePasswordPost(ChangePasswordRequest $request)
{
$user = Auth::user();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"avored/cash-on-delivery": "~1.2",
"avored/contact": "~1.2",
"avored/dummy-data": "~1.4",
"avored/ecommerce": "~1.8",
"avored/ecommerce": "~1.9",
"avored/featured": "~1.7",
"avored/fixed-rate": "~1.5",
"avored/module-installer": "1.*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}
},
methods:{
onChange: function(){
onChange: function(event){
this.$emit('change', event.target.value, this.fieldName);
if( event.target.value != "") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
}
},
methods:{
onChange: function(){
onChange: function(event){
this.$emit('change', event.target.value, this.fieldName);
if( event.target.value != "") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
}
},
methods:{
onChange: function(){
onChange: function(event){
this.$emit('change', event.target.value, this.fieldName);
if( event.target.value != "") {
Expand Down
34 changes: 0 additions & 34 deletions modules/avored/ecommerce/src/DataGrid/Category.php

This file was deleted.

45 changes: 45 additions & 0 deletions modules/avored/ecommerce/src/DataGrid/CategoryDataGrid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace AvoRed\Ecommerce\DataGrid;

use AvoRed\Framework\DataGrid\Facade as DataGrid;
use AvoRed\Framework\DataGrid\Columns\TextColumn;

class CategoryDataGrid
{
public $dataGrid;

public function __construct($model)
{
$dataGrid = DataGrid::make('admin_category_controller');

$dataGrid->model($model)
->column('name', function (TextColumn $column) {
$column->identifier('name')
->label('Name')
->sortable(true)
->canFilter(true);
})
->column('slug', function (TextColumn $column) {
$column->identifier('slug')
->label('Slug')
->sortable(true)
->canFilter(true);
})
->linkColumn('edit', [], function ($model) {
return "<a href='" . route('admin.category.edit', $model->id) . "' >Edit</a>";
})->linkColumn('destroy', [], function ($model) {
return "<form id='admin-category-destroy-" . $model->id . "'
method='POST'
action='" . route('admin.category.destroy', $model->id) . "'>
<input name='_method' type='hidden' value='DELETE' />
" . csrf_field() . "
<a href='#'
onclick=\"jQuery('#admin-category-destroy-$model->id').submit()\"
>Destroy</a>
</form>";
});

$this->dataGrid = $dataGrid;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace AvoRed\Ecommerce\Http\Controllers;

use AvoRed\Framework\Models\Database\Category as Model;
use AvoRed\Ecommerce\DataGrid\Category;
use AvoRed\Ecommerce\Http\Requests\CategoryRequest;
use AvoRed\Framework\Models\Contracts\CategoryInterface;
use AvoRed\Ecommerce\DataGrid\CategoryDataGrid;

class CategoryController extends Controller
{
Expand All @@ -27,7 +27,7 @@ public function __construct(CategoryInterface $repository)
*/
public function index()
{
$categoryGrid = new Category($this->repository->query());
$categoryGrid = new CategoryDataGrid($this->repository->query());

return view('avored-ecommerce::category.index')->with('dataGrid', $categoryGrid->dataGrid);
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"avored:admin": "npm run production -- --env.mixfile=avored.admin.webpack.mix",
"avored:watch": "npm run production -- --env.mixfile=avored.admin.webpack.mix --watch",
"avored:admin:prod": "npm run production -- --env.mixfile=avored.admin.webpack.mix",
"avored:admin:watch": "npm run development -- --env.mixfile=avored.admin.webpack.mix --watch",
"avored:admin:dev": "npm run development -- --env.mixfile=avored.admin.webpack.mix",
"postinstall": "opencollective postinstall"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion public/vendor/avored-admin/js/app.js

Large diffs are not rendered by default.

0 comments on commit ade803b

Please sign in to comment.