Merge pull request #63 from bagisto/prashant

Prashant
This commit is contained in:
JItendra Singh 2018-10-18 10:46:46 +05:30 committed by GitHub
commit e2229bc634
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 336 additions and 176 deletions

View File

@ -402,14 +402,27 @@ Route::group(['middleware' => ['web']], function () {
])->name('admin.sliders.index');
// Admin Store Front Settings Route
Route::get('/slider/create','Webkul\Shop\Http\Controllers\SliderController@create')->defaults('_config',[
//slider create
Route::get('slider/create','Webkul\Shop\Http\Controllers\SliderController@create')->defaults('_config',[
'view' => 'admin::settings.sliders.create'
])->name('admin.sliders.create');
Route::post('/slider/create','Webkul\Shop\Http\Controllers\SliderController@store')->defaults('_config',[
Route::post('slider/create','Webkul\Shop\Http\Controllers\SliderController@store')->defaults('_config',[
'redirect' => 'admin::sliders.index'
])->name('admin.sliders.store');
//slider edit
Route::get('slider/edit/{id}','Webkul\Shop\Http\Controllers\SliderController@edit')->defaults('_config',[
'view' => 'admin::settings.sliders.edit'
])->name('admin.sliders.edit');
Route::post('slider/edit/{id}','Webkul\Shop\Http\Controllers\SliderController@update')->defaults('_config',[
'redirect' => 'admin::sliders.index'
])->name('admin.sliders.update');
//destroy a slider item
Route::get('slider/delete/{id}', 'Webkul\Shop\Http\Controllers\SliderController@destroy');
//tax routes
Route::get('/tax-categories', 'Webkul\Tax\Http\Controllers\TaxController@index')->defaults('_config', [

View File

@ -31,11 +31,14 @@
<span class="control-error" v-if="errors.has('title')">@{{ errors.first('title') }}</span>
</div>
<?php $channels = core()->getAllChannels() ?>
<div class="control-group" :class="[errors.has('channel_id') ? 'has-error' : '']">
<label for="channel_id">{{ __('admin::app.settings.sliders.channels') }}</label>
<select class="control" id="channel_id" name="channel_id" value="" v-validate="'required'">
@foreach($channels[0] as $channel)
<option value="{{ $channel->id }}">{{ __($channel->name) }}</option>
<select class="control" id="channel_id" name="channel_id" v-validate="'required'">
@foreach($channels as $channel)
<option value="{{ $channel->id }}" @if($channel->id == old('channel_id')) selected @endif>
{{ __($channel->name) }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('channel_id')">@{{ errors.first('channel_id') }}</span>

View File

@ -0,0 +1,69 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('admin::app.settings.sliders.add-title') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.sliders.update', $slider->id) }}" @submit.prevent="onSubmit" enctype="multipart/form-data">
<div class="page-header">
<div class="page-title">
<h1>{{ __('admin::app.settings.sliders.add-title') }}</h1>
</div>
<div class="page-action">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('admin::app.settings.sliders.save-btn-title') }}
</button>
</div>
</div>
<div class="page-content">
<div class="form-container">
@csrf()
<div class="control-group" :class="[errors.has('title') ? 'has-error' : '']">
<label for="title">{{ __('admin::app.settings.sliders.title') }}</label>
<input type="text" class="control" name="title" v-validate="'required'" value="{{ $slider->title ?: old('title') }}">
<span class="control-error" v-if="errors.has('title')">@{{ errors.first('title') }}</span>
</div>
<?php $channels = core()->getAllChannels() ?>
<div class="control-group" :class="[errors.has('channel_id') ? 'has-error' : '']">
<label for="channel_id">{{ __('admin::app.settings.sliders.channels') }}</label>
<select class="control" id="channel_id" name="channel_id" value="" v-validate="'required'">
@foreach($channels as $channel)
<option value="{{ $channel->id }}" @if($channel->id == $slider->channel_id) selected @endif>
{{ __($channel->name) }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('channel_id')">@{{ errors.first('channel_id') }}</span>
</div>
<div class="control-group" :class="[errors.has('image') ? 'has-error' : '']">
<label for="new_image">{{ __('admin::app.settings.sliders.image') }}</label>
<image-upload>
<input type="file" class="control" id="add_image" name="image" value="" v-validate="'image|required'" placeholder="Upload Image" />
<span class="control-error" v-if="errors.has('image')">@{{ errors.first('image') }}</span>
</image-upload>
</div>
<div class="control-group" :class="[errors.has('content') ? 'has-error' : '']">
<label for="content">{{ __('admin::app.settings.sliders.content') }}</label>
<textarea class="control" id="add_content" name="content" v-validate="'required'" rows="5">{{ $slider->content ? : old('content') }}</textarea>
<span class="control-error" v-if="errors.has('content')">@{{ errors.first('content') }}</span>
</div>
</div>
</div>
</form>
</div>
@endsection

View File

@ -2,7 +2,10 @@
namespace Webkul\Core\Repositories;
use Illuminate\Container\Container as App;
use Webkul\Core\Eloquent\Repository;
use Webkul\Core\Repositories\ChannelRepository as Channel;
use Storage;
/**
* Slider Reposotory
@ -12,6 +15,18 @@ use Webkul\Core\Eloquent\Repository;
*/
class SliderRepository extends Repository
{
protected $channel;
public function __construct(
Channel $channel,
App $app
)
{
$this->channel = $channel;
parent::__construct($app);
}
/**
* Specify Model class name
*
@ -28,15 +43,52 @@ class SliderRepository extends Repository
*/
public function create(array $data)
{
$image = request()->file('image');
$image_name = uniqid(20).'.'.$image->getClientOriginalExtension();
$channelName = $this->channel->find($data['channel_id'])->name;
$dir = 'slider_images/' . $channelName;
$image = request()->file('image')->store($dir);
unset($data['image'], $data['_token']);
$data['path'] = $image;
$destinationPath = public_path('/vendor/webkul/shop/assets/images/slider');
$path = $image->move($destinationPath, $image_name);
$path= 'vendor/webkul/shop/assets/images/slider/'.$image_name;
$data['path'] = $path;
$this->model->create($data);
}
/**
* @param array $data
* @return mixed
*/
public function updateItem(array $data, $id)
{
$channelName = $this->channel->find($data['channel_id'])->name;
$dir = 'slider_images/' . $channelName;
$image = request()->file('image')->store($dir);
unset($data['image'], $data['_token']);
$data['path'] = $image;
$this->update($data, $id);
}
/**
* Delete a slider item and delete the image from the disk or where ever it is
*
* @return Boolean
*/
public function destroy($id) {
$sliderItem = $this->find($id);
$sliderItemImage = $sliderItem->path;
Storage::delete($sliderItemImage);
return $this->model->destroy($id);
}
}

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CustomersPasswordResets extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('customers_password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('customers_password_resets');
}
}

View File

@ -28,7 +28,6 @@ class AddressController extends Controller
protected $customer;
protected $address;
public function __construct(CustomerRepository $customer, CustomerAddressRepository $address)
{
$this->middleware('customer');
@ -41,22 +40,9 @@ class AddressController extends Controller
}
/**
* Getting logged in
* customer helper
* @return Array
*/
private function getCustomer($id) {
$customer = collect($this->customer->findOneWhere(['id'=>$id]));
return $customer;
}
/**
* Getting logged in
* customer address
* helper
* @return Array
* Getting logged in customer address helper
*
* @return array
*/
private function getAddress($id) {
@ -66,37 +52,32 @@ class AddressController extends Controller
}
/**
* Address Route
* index page
* @return View
* Address Route index page
*
* @return view
*/
public function index() {
$id = auth()->guard('customer')->user()->id;
$customer = $this->getCustomer($id);
$address = $this->getAddress($id);
return view($this->_config['view'])->with('address', $address);
}
/**
* Show the address
* create form
* @return View
* Show the address create form
*
* @return view
*/
public function show() {
return view($this->_config['view']);
}
/**
* Create a new
* address for
* customer.
* Create a new address for customer.
*
* @return View
* @return view
*/
public function create() {
@ -144,11 +125,9 @@ class AddressController extends Controller
}
/**
* For editing the
* existing address
* of the customer
* For editing the existing address of the customer
*
* @return View
* @return view
*/
public function showEdit() {
@ -160,6 +139,12 @@ class AddressController extends Controller
}
/**
* Edits the premade resource of customer called
* Address.
*
* @return redirect
*/
public function edit() {
$id = auth()->guard('customer')->user()->id;

View File

@ -10,10 +10,7 @@ use Webkul\Customer\Models\Customer;
use Auth;
/**
* Customer controlller for the customer
* basically for the tasks of customers
* which will be done after customer
* authenticastion.
* Customer controlller for the customer basically for the tasks of customers which will be done after customer authentication.
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
@ -36,7 +33,7 @@ class CustomerController extends Controller
protected $productReview;
/**
* Create a new controller instance.
* Create a new Repository instance.
*
* @param Webkul\Product\Repositories\ProductReviewRepository $productReview
* @return void
@ -54,9 +51,8 @@ class CustomerController extends Controller
}
/**
* For taking the customer
* to the dashboard after
* authentication
* For taking the customer to the dashboard after authentication
*
* @return view
*/
private function getCustomer($id) {
@ -65,9 +61,8 @@ class CustomerController extends Controller
}
/**
* Taking the customer
* to profile details
* page
* Taking the customer to profile details page
*
* @return View
*/
public function index() {
@ -79,8 +74,7 @@ class CustomerController extends Controller
}
/**
* For loading the
* edit form page.
* For loading the edit form page.
*
* @return View
*/
@ -93,9 +87,7 @@ class CustomerController extends Controller
}
/**
* Edit function
* for editing customer
* profile.
* Edit function for editing customer profile.
*
* @return Redirect.
*/
@ -148,23 +140,40 @@ class CustomerController extends Controller
}
}
/**
* Load the view for the customer account panel, showing orders in a table.
*
* @return Mixed
*/
public function orders() {
return view($this->_config['view']);
}
/**
* Load the view for the customer account panel, showing wishlist items.
*
* @return Mixed
*/
public function wishlist() {
return view($this->_config['view']);
}
/**
* Load the view for the customer account panel, showing approved reviews.
*
* @return Mixed
*/
public function reviews() {
$id = auth()->guard('customer')->user()->id;
$reviews = $this->productReview->getCustomerReview($id);
$reviews = $this->productReview->getCustomerReview();
return view($this->_config['view'],compact('reviews'));
}
/**
* Load the view for the customer account panel, shows the customer address.
*
* @return Mixed
*/
public function address() {
return view($this->_config['view']);
}

View File

@ -1,61 +0,0 @@
<?php
namespace Webkul\Customer\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Customer\Repositories\CustomerRepository;
use Auth;
/**
* Customer controlller for the customer
* basically for the tasks of customers
* which will be done after customer
* authenticastion.
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class ReviewsController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
protected $_config;
protected $customer;
public function __construct(CustomerRepository $customer)
{
$this->middleware('customer');
$this->_config = request('_config');
$this->customer = $customer;
}
/**
* For taking the customer
* to the dashboard after
* authentication
* @return view
*/
private function getCustomer($id) {
$customer = collect($this->customer->findOneWhere(['id'=>$id]));
return $customer;
}
public function index() {
$id = auth()->guard('customer')->user()->id;
$customer = $this->getCustomer($id);
return view($this->_config['view'])->with('customer', $customer);
}
public function reviews() {
return view($this->_config['view']);
}
}

View File

@ -14,7 +14,7 @@ use Webkul\Product\Repositories\ProductRepository;
*/
class ProductReviewRepository extends Repository
{
/**
/**
* ProductImageRepository object
*
* @var array
@ -51,9 +51,13 @@ class ProductReviewRepository extends Repository
*
* @param int $customerId
*/
function getCustomerReview($customerId)
function getCustomerReview()
{
$reviews = $this->model->where('customer_id',$customerId)->with('product')->get();
$customerId = auth()->guard('customer')->user()->id;
$reviews = $this->model->where(['customer_id'=> $customerId, 'status' => 'approved'])->with('product')->get();
// dd($reviews);
return $reviews;
}

View File

@ -46,6 +46,10 @@ class ReviewController extends Controller
*/
public function __construct(Product $product, ProductReview $productReview)
{
$this->middleware('admin');
$this->middleware('customer')->only(['create', 'store']);
$this->product = $product;
$this->productReview = $productReview;
@ -118,7 +122,7 @@ class ReviewController extends Controller
return view($this->_config['view'],compact('product'));
}
/**
/**
* Show the form for editing the specified resource.
*
* @param int $id
@ -131,7 +135,7 @@ class ReviewController extends Controller
return view($this->_config['view'],compact('review'));
}
/**
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request

View File

@ -45,16 +45,63 @@ class SliderController extends controller
public function create() {
$channels = core()->getAllChannels();
return view($this->_config['view'])->with('channels',[$channels]);
return view($this->_config['view']);
}
/**
* Creates the new
* sider item
* Creates the new sider item.
*
* @return response
*/
public function store() {
$this->slider->create(request()->all());
session()->flash('success', 'Slider created successfully.');
return redirect()->back();
}
/**
* Edit the previously created slider item.
*
* @return mixed
*/
public function edit($id) {
$slider = $this->slider->find($id);
return view($this->_config['view'])->with('slider', $slider);
}
/**
* Edit the previously created slider item.
*
* @return response
*/
public function update($id) {
if($this->slider->updateItem(request()->all(), $id)) {
session()->flash('success', 'Slider Item Successfully Updated');
} else {
session()->flash('error', 'Slider Cannot Be Updated');
}
return redirect()->back();
}
/**
* Delete a slider item and preserve the last one from deleting
*
* @return mixed
*/
public function destroy($id) {
if($this->slider->findWhere(['channel_id' => core()->getCurrentChannel()->id])->count() == 1) {
session()->flash('warning', 'Cannot Delete The Last Slider Item');
} else {
$this->slider->destroy($id);
session()->flash('success', 'Slider Item Successfully Deleted');
}
return redirect()->back();
}
}

View File

@ -66,10 +66,6 @@ Route::group(['middleware' => ['web', 'theme', 'locale']], function () {
'redirect' => 'customer.reviews.index'
])->name('shop.reviews.store');
// Route::post('/reviews/create/{slug}', 'Webkul\Shop\Http\Controllers\ReviewController@store')->defaults('_config', [
// 'redirect' => 'admin.reviews.index'
// ])->name('admin.reviews.store');
// forgot Password Routes
Route::get('/forgot-password', 'Webkul\Customer\Http\Controllers\ForgotPasswordController@create')->defaults('_config', [
'view' => 'shop::customers.signup.forgot-password'

View File

@ -25,6 +25,11 @@ export default {
type: Array,
required: true,
default: () => [],
},
public_path: {
type: String,
required: true,
}
},
@ -53,8 +58,9 @@ export default {
setProps() {
var this_this = this;
this.slides.forEach(function(slider) {
this_this.images.push(slider.path);
this_this.images.push(this_this.public_path+'/storage/'+slider.path);
});
this.currentIndex = 0;

View File

@ -299,21 +299,12 @@ section.slider-block {
div.slider-control {
display: flex;
justify-content:space-between;
bottom: 48%;
bottom: 46%;
right: 0%;
width:100%;
.dark-left-icon {
margin-left: 15px;
}
.light-right-icon {
margin-right: 15px;
}
}
}
}
}
//header navigation

View File

@ -13,7 +13,6 @@
<div class="account-layout">
<div class="account-head">
<span class="back-icon"><a href="{{ route('customer.account.index') }}"><i class="icon icon-menu-back"></i></a></span>
<span class="account-heading">{{ __('shop::app.customer.account.address.index.title') }}</span>
@if(!$address->isEmpty())

View File

@ -1,4 +1,4 @@
<div class="responsive-side-menu" id="responsive-side-menu">
<div class="responsive-side-menu" id="responsive-side-menu" style="display:none">
Menu
<i class="icon icon-arrow-down right" id="down-icon"></i>
</div>

View File

@ -12,7 +12,7 @@
<div class="account-head">
<span class="back-icon"><a href="{{ route('customer.account.index') }}"><i class="icon icon-menu-back"></i></a></span>
{{-- <span class="back-icon"><a href="{{ route('customer.account.index') }}"><i class="icon icon-menu-back"></i></a></span> --}}
<span class="account-heading">{{ __('shop::app.customer.account.profile.index.title') }}</span>

View File

@ -8,7 +8,8 @@
<div class="account-layout">
<div class="account-head">
<span class="back-icon"><a href="{{ route('customer.account.index') }}"><i class="icon icon-menu-back"></i></a></span>
{{-- <span class="back-icon"><a href="{{ route('customer.account.index') }}"><i class="icon icon-menu-back"></i></a></span> --}}
<span class="account-heading">{{ __('shop::app.customer.account.review.index.title') }}</span>
<span></span>
<div class="horizontal-rule"></div>
@ -16,7 +17,7 @@
<div class="account-items-list">
@if(is_null($reviews))
@if(!is_null($reviews))
@foreach($reviews as $review)
<div class="account-item-card mt-15 mb-15">
<div class="media-info">

View File

@ -12,7 +12,6 @@
<div class="account-head mb-15">
<span class="account-heading">{{ __('shop::app.wishlist.title') }}</span>
<span class="account-heading">{{ __('shop::app.wishlist.title') }}</span>
@if(count($items))
<div class="account-action">
<a href="" style="margin-right: 15px;">{{ __('shop::app.wishlist.deleteall') }}</a>

View File

@ -1,3 +1,3 @@
<section class="slider-block">
<image-slider :slides='@json($sliderData)'> </image-slider>
<image-slider :slides='@json($sliderData)' public_path="{{ url()->to('/') }}"></image-slider>
</section>

View File

@ -80,24 +80,22 @@
@endsection
@push('scripts')
<script>
<script>
document.onreadystatechange = function () {
var state = document.readyState
var galleryTemplate = document.getElementById('product-gallery-template');
var addTOButton = document.getElementsByClassName('add-to-buttons')[0];
document.onreadystatechange = function () {
var state = document.readyState
var galleryTemplate = document.getElementById('product-gallery-template');
var addTOButton = document.getElementsByClassName('add-to-buttons')[0];
if(galleryTemplate){
if (state == 'interactive') {
galleryTemplate.style.display="none";
} else {
document.getElementById('loader').style.display="none";
addTOButton.style.display="flex";
if(galleryTemplate){
if (state == 'interactive') {
galleryTemplate.style.display="none";
} else {
document.getElementById('loader').style.display="none";
// addTOButton.style.display="flex";
}
}
}
}
</script>
</script>
@endpush

View File

@ -29,16 +29,23 @@
mounted: function() {
this.sample = "";
var element = this.$el.getElementsByTagName("input")[0];
var this_this = this;
element.onchange = function() {
var fReader = new FileReader();
fReader.readAsDataURL(element.files[0]);
fReader.onload = function(event) {
this.img = document.getElementsByTagName("input")[0];
this.img.src = event.target.result;
this_this.newImage = this.img.src;
this_this.changePreview();
};
}

File diff suppressed because one or more lines are too long