customer edit/add & show in admin
This commit is contained in:
parent
d0e0b64445
commit
b082d73707
|
|
@ -37,7 +37,8 @@
|
|||
"webkul/laravel-category": "self.version",
|
||||
"webkul/laravel-product": "self.version",
|
||||
"webkul/laravel-shop": "self.version",
|
||||
"webkul/laravel-theme": "self.version"
|
||||
"webkul/laravel-theme": "self.version",
|
||||
"webkul/laravel-shipping": "self.version"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
|
|
@ -57,7 +58,8 @@
|
|||
"Webkul\\Inventory\\": "packages/Webkul/Inventory/src",
|
||||
"Webkul\\Product\\": "packages/Webkul/Product/src",
|
||||
"Webkul\\Theme\\": "packages/Webkul/Theme/src",
|
||||
"Webkul\\Cart\\": "packages/Webkul/Cart/src"
|
||||
"Webkul\\Cart\\": "packages/Webkul/Cart/src",
|
||||
"Webkul\\Shipping\\": "packages/Webkul/Shipping/src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ return [
|
|||
Webkul\Customer\Providers\CustomerServiceProvider::class,
|
||||
Webkul\Theme\Providers\ThemeServiceProvider::class,
|
||||
Webkul\Cart\Providers\CartServiceProvider::class,
|
||||
Webkul\Shipping\Providers\ShippingServiceProvider::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
|
||||
[
|
||||
'code' => 'flatrate',
|
||||
'title' => 'Flat Rate',
|
||||
'description' => 'this is a flat rate',
|
||||
'status' => '1',
|
||||
'type' => [
|
||||
'per unit' => 'Per Unit',
|
||||
'per order' => 'Per Order',
|
||||
],
|
||||
]
|
||||
]
|
||||
|
||||
?>
|
||||
|
|
@ -53,6 +53,14 @@ Route::group(['middleware' => ['web']], function () {
|
|||
'view' => 'admin::customers.review.index'
|
||||
])->name('admin.customer.review.index');
|
||||
|
||||
Route::get('customer/create', 'Webkul\Core\Http\Controllers\CustomerController@create')->defaults('_config',[
|
||||
'view' => 'admin::customers.create'
|
||||
])->name('admin.customer.create');
|
||||
|
||||
Route::post('customer/create', 'Webkul\Core\Http\Controllers\CustomerController@store')->defaults('_config',[
|
||||
'redirect' => 'admin.customer.index'
|
||||
])->name('admin.customer.store');
|
||||
|
||||
Route::get('customer/reviews/edit/{id}', 'Webkul\Shop\Http\Controllers\ReviewController@edit')->defaults('_config',[
|
||||
'view' => 'admin::customers.review.edit'
|
||||
])->name('admin.customer.review.edit');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
@extends('admin::layouts.content')
|
||||
|
||||
@section('content')
|
||||
<div class="content">
|
||||
<form method="POST" action="{{ route('admin.customer.store') }}">
|
||||
|
||||
<div class="page-header">
|
||||
<div class="page-title">
|
||||
<h1>
|
||||
{{ __('admin::app.customers.customers.title') }}
|
||||
|
||||
{{ Config::get('carrier.social.facebook.url') }}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="page-action">
|
||||
<button type="submit" class="btn btn-lg btn-primary">
|
||||
{{ __('admin::app.account.save-btn-title') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
|
||||
<div class="form-container">
|
||||
@csrf()
|
||||
|
||||
<accordian :title="'{{ __('admin::app.account.general') }}'" :active="true">
|
||||
<div slot="body">
|
||||
|
||||
<div class="control-group" :class="[errors.has('first_name') ? 'has-error' : '']">
|
||||
<label for="first_name">{{ __('shop::app.customer.signup-form.firstname') }}</label>
|
||||
<input type="text" class="control" name="first_name" v-validate="'required'" value="{{ old('first_name') }}">
|
||||
<span class="control-error" v-if="errors.has('first_name')">@{{ errors.first('first_name') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('last_name') ? 'has-error' : '']">
|
||||
<label for="last_name">{{ __('shop::app.customer.signup-form.lastname') }}</label>
|
||||
<input type="text" class="control" name="last_name" v-validate="'required'" value="{{ old('last_name') }}">
|
||||
<span class="control-error" v-if="errors.has('last_name')">@{{ errors.first('last_name') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('email') ? 'has-error' : '']">
|
||||
<label for="email">{{ __('shop::app.customer.signup-form.email') }}</label>
|
||||
<input type="email" class="control" name="email" v-validate="'required|email'" value="{{ old('email') }}">
|
||||
<span class="control-error" v-if="errors.has('email')">@{{ errors.first('email') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="gender">{{ __('admin::app.customers.customers.gender') }}</label>
|
||||
<select name="gender" class="control" v-validate="'required'">
|
||||
<option value="Male">Male</option>
|
||||
<option value="Female">Female</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="dob">{{ __('admin::app.customers.customers.date_of_birth') }}</label>
|
||||
<input type="date" class="control" name="date_of_birth" v-validate="'required'">
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="phone">{{ __('admin::app.customers.customers.phone') }}</label>
|
||||
<input type="text" class="control" name="phone" v-validate="'required'">
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="name" >{{ __('admin::app.customers.customers.customer_group') }}</label>
|
||||
<select class="control" name="customer_group_id">
|
||||
@foreach ($customerGroup as $group)
|
||||
<option value="{{ $group->id }}"> {{ $group->group_name}} </>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</accordian>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@stop
|
||||
|
|
@ -63,11 +63,14 @@
|
|||
|
||||
<div class="control-group">
|
||||
<label for="name" >{{ __('admin::app.customers.customers.customer_group') }}</label>
|
||||
<?php $selectedOption = $customer->customerGroup->id ?>
|
||||
<select class="control" name="customer_group_id">
|
||||
<option value="1"> 1 </option>
|
||||
<option value="2"> 2 </option>
|
||||
<option value="3"> 3 </option>
|
||||
<option value="4"> 4 </option>
|
||||
@foreach($customerGroup as $group)
|
||||
<option value="{{ $group->id }}" {{ $selectedOption == $group->id ? 'selected' : '' }}>
|
||||
{{ $group->group_name}}
|
||||
</option>
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
<h1>{{ __('admin::app.customers.customers.title') }}</h1>
|
||||
</div>
|
||||
<div class="page-action">
|
||||
<a href="{{ route('admin.users.create') }}" class="btn btn-lg btn-primary">
|
||||
<a href="{{ route('admin.customer.create') }}" class="btn btn-lg btn-primary">
|
||||
{{ __('Add Customer') }}
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ namespace Webkul\Core\Http\Controllers;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Webkul\Customer\Models\Customer;
|
||||
use Webkul\Customer\Repositories\CustomerRepository as Customer;
|
||||
use Webkul\Customer\Repositories\CustomerGroupRepository as CustomerGroup;
|
||||
|
||||
/**
|
||||
* Customer controlller for the customer
|
||||
|
|
@ -17,15 +18,40 @@ use Webkul\Customer\Models\Customer;
|
|||
class CustomerController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* Contains route related configuration
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @var array
|
||||
*/
|
||||
protected $_config;
|
||||
|
||||
public function __construct()
|
||||
/**
|
||||
* CustomerRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customer;
|
||||
|
||||
/**
|
||||
* CustomerGroupRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $customerGroup;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Customer\Repositories\CustomerRepository as customer;
|
||||
* @param Webkul\Customer\Repositories\CustomerGroupRepository as customerGroup;
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Customer $customer , CustomerGroup $customerGroup )
|
||||
{
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->customer = $customer;
|
||||
|
||||
$this->customerGroup = $customerGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -38,6 +64,47 @@ class CustomerController extends Controller
|
|||
return view($this->_config['view']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$customerGroup = $this->customerGroup->all();
|
||||
|
||||
return view($this->_config['view'],compact('customerGroup'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
|
||||
'first_name' => 'string|required',
|
||||
'last_name' => 'string|required',
|
||||
'email' => 'email|required',
|
||||
|
||||
]);
|
||||
|
||||
$data=$request->all();
|
||||
|
||||
$password = bcrypt(rand(100000,10000000));
|
||||
|
||||
$data['password']=$password;
|
||||
|
||||
$this->customer->create($data);
|
||||
|
||||
session()->flash('success', 'Customer created successfully.');
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
|
|
@ -46,11 +113,11 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$customer = Customer::find($id);
|
||||
$customer = $this->customer->findOneWhere(['id'=>$id]);
|
||||
|
||||
dd($customer->customerGroup->group_name);
|
||||
$customerGroup = $this->customerGroup->all();
|
||||
|
||||
return view($this->_config['view'],compact('customer'));
|
||||
return view($this->_config['view'],compact('customer','customerGroup'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -62,9 +129,8 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$customer = Customer::find($id);
|
||||
|
||||
$customer->update(request()->all(), [$id]);
|
||||
$this->customer->update(request()->all(),$id);
|
||||
|
||||
session()->flash('success', 'Customer updated successfully.');
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class CreateCustomersTable extends Migration
|
|||
$table->date('date_of_birth')->nullable();
|
||||
$table->string('phone')->unique()->nullable();
|
||||
$table->string('email')->unique();
|
||||
$table->tinyInteger('status')->default(1);
|
||||
$table->string('password');
|
||||
$table->integer('customer_group_id')->unsigned()->nullable();
|
||||
$table->foreign('customer_group_id')->references('id')->on('customer_groups')->onDelete('cascade');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Customer\Repositories;
|
||||
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
/**
|
||||
* CustomerGroup Reposotory
|
||||
*
|
||||
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
|
||||
class CustomerGroupRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
function model()
|
||||
{
|
||||
return 'Webkul\Customer\Models\CustomersGroups';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function create(array $data)
|
||||
{
|
||||
$customer = $this->model->create($data);
|
||||
|
||||
return $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param $id
|
||||
* @param string $attribute
|
||||
* @return mixed
|
||||
*/
|
||||
|
||||
public function update(array $data, $id, $attribute = "id")
|
||||
{
|
||||
$customer = $this->find($id);
|
||||
|
||||
$customer->update($data);
|
||||
|
||||
return $customer;
|
||||
}
|
||||
}
|
||||
|
|
@ -78,12 +78,12 @@ class Review extends AbstractProduct
|
|||
return $percentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the of the product
|
||||
*
|
||||
/**
|
||||
* Returns the product accroding to paginate
|
||||
*
|
||||
* @param Product $product
|
||||
* @return integer
|
||||
*/
|
||||
* @return integer
|
||||
*/
|
||||
|
||||
public function loadMore($product)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "webkul/laravel-shipping",
|
||||
"description": "Shipping Package for Shipping Method",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "rahulshukla-webkul",
|
||||
"email": "rahulshukla.symfony517@webkul.com"
|
||||
}
|
||||
],
|
||||
"require": {},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Webkul\\Shipping\\": "src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Webkul\\Cart\\Providers\\ShippingServiceProvider"
|
||||
],
|
||||
"aliases": {}
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Shipping\Contracts;
|
||||
|
||||
/**
|
||||
* Interface ShippingInterface
|
||||
* @author Rahul Shukla <rahulshukla.symfony517@webkul.com>
|
||||
*/
|
||||
|
||||
interface ShippingInterface
|
||||
{
|
||||
|
||||
public function calculate();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Shipping\Helpers;
|
||||
|
||||
|
||||
use Webkul\Shipping\Contracts\ShippingInterface;
|
||||
|
||||
/**
|
||||
* Class Rate.
|
||||
*
|
||||
* @package namespace App\Criteria;
|
||||
*/
|
||||
class Rate implements ShippingInterface
|
||||
{
|
||||
|
||||
public function calculate()
|
||||
{
|
||||
return 'gg';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Shipping\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Routing\Router;
|
||||
use Webkul\Customer\Http\Middleware\RedirectIfNotCustomer;
|
||||
|
||||
class ShippingServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Router $router)
|
||||
{
|
||||
|
||||
$router->aliasMiddleware('customer', RedirectIfNotCustomer::class);
|
||||
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../Database/migrations');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -106,18 +106,13 @@
|
|||
<th class="grid_head" data-column-name="{{ $column->alias }}" data-column-label="{{ $column->label }}">{!! $column->sorting() !!}</th>
|
||||
@endif
|
||||
@endforeach
|
||||
<td>Name</td>
|
||||
{{-- @if(isset($attribute_columns))
|
||||
@if(isset($attribute_columns))
|
||||
@foreach($attribute_columns as $key => $value)
|
||||
<th class="grid_head"
|
||||
data-column-name="{{ $attributeAliases[$key] }}"
|
||||
data-column-label="{{ $attributeAliases[$key] }}"
|
||||
data-column-sort="asc"
|
||||
>
|
||||
{{ $value }}<span class="icon sort-down-icon"></span>
|
||||
<th>
|
||||
{{ $value }}
|
||||
</th>
|
||||
@endforeach
|
||||
@endif --}}
|
||||
@endif
|
||||
<th>
|
||||
Actions
|
||||
</th>
|
||||
|
|
@ -136,12 +131,12 @@
|
|||
@foreach ($columns as $column)
|
||||
<td class="">{!! $column->render($result) !!}</td>
|
||||
@endforeach
|
||||
{{-- @if(isset($attribute_columns))
|
||||
|
||||
@if(isset($attribute_columns))
|
||||
@foreach ($attribute_columns as $atc)
|
||||
<td>{{ $result->{$atc} }}</td>
|
||||
@endforeach
|
||||
@endif --}}
|
||||
<td></td>
|
||||
@endif
|
||||
|
||||
<td class="action">
|
||||
@foreach($actions as $action)
|
||||
|
|
|
|||
Loading…
Reference in New Issue