Before merge

This commit is contained in:
prashant-webkul 2018-08-22 15:16:27 +05:30
parent 8dec681e49
commit 4403fedc89
6 changed files with 91 additions and 21 deletions

View File

@ -5,7 +5,7 @@ namespace Webkul\Customer\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Webkul\Customer\Models\Customer;
use Webkul\Customer\Repositories\CustomerRepository;
/**
* Dashboard controller
@ -45,23 +45,30 @@ class RegistrationController extends Controller
{
// return $request->except('_token'); //don't let csrf token to be openly printed
$request->validate([
'first_name' => 'string|required',
'last_name' => 'string|required',
'email' => 'email|required',
'password' => 'confirmed|min:8|required'
'password' => 'confirmed|min:6|required'
]);
$customer = new \Webkul\Customer\Models\Customer();
$customer->first_name = $request->first_name;
$customer->last_name = $request->last_name;
$customer->email = $request->email;
$customer->password = bcrypt($request->password);
// dd('hello1');
if ($customer->save()) {
session()->flash('success', 'Account created successfully.');
return redirect()->route($this->_config['redirect']);
} else {
session()->flash('error', 'Cannot Create Your Account.');
return redirect()->back();
}
}
}

View File

@ -0,0 +1,54 @@
<?php
namespace Webkul\Customer\Repositories;
use Webkul\Customer\Eloquent\Repository;
/**
* Customer Reposotory
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CustomerRepository extends Repository
{
/**
* Specify Model class name
*
* @return mixed
*/
function model()
{
return 'Webkul\Customer\Models\Customer';
}
/**
* @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->findOrFail($id);
$customer->update($data);
return $customer;
}
}

View File

@ -12,50 +12,59 @@
<form method="post" action="{{ route('customer.register.create') }}">
<div class="edit-form">
{{ csrf_field() }}
<div class="control-group">
<label for="first_name">First Name</label>
<input type="text" class="control" name="first_name" value="{{ $customer['first_name'] }}" v-validate="'required'"> {{-- <span>@{{ errors.first('first_name') }}</span> --}}
<input type="text" class="control" name="first_name" value="{{ $customer['first_name'] }}" v-validate="'required'">
<span>@{{ errors.first('first_name') }}</span>
</div>
<div class="control-group">
<label for="last_name">Last Name</label>
<input type="text" class="control" name="last_name" value="{{ $customer['last_name'] }}" v-validate="'required'"> {{-- <span>@{{ errors.first('last_name') }}</span> --}}
<input type="text" class="control" name="last_name" value="{{ $customer['last_name'] }}" v-validate="'required'">
<span>@{{ errors.first('last_name') }}</span>
</div>
<div class="control-group">
<label for="email">Email</label>
<input type="email" class="control" name="email" value="{{ $customer['email'] }}" v-validate="'required'"> {{-- <span>@{{ errors.first('email') }}</span> --}}
<input type="email" class="control" name="email" value="{{ $customer['email'] }}" v-validate="'required'">
<span>@{{ errors.first('email') }}</span>
</div>
<div class="control-group">
<label for="email">Gender</label>
<select name="gender" class="control" value="{{ $customer['gender'] }}" v-validate="'required'">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select> {{-- <span>@{{ errors.first('gender') }}</span> --}}
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
<span>@{{ errors.first('gender') }}</span>
</div>
<div class="control-group">
<label for="dob">Date of Birth</label>
<input type="date" class="control" name="dob" value="{{ $customer['date_of_birth'] }}" v-validate="'required'"> {{-- <span>@{{ errors.first('first_name') }}</span> --}}
<input type="date" class="control" name="dob" value="{{ $customer['date_of_birth'] }}" v-validate="'required'">
<span>@{{ errors.first('first_name') }}</span>
</div>
<div class="control-group">
<label for="phone">Phone</label>
<input type="text" class="control" name="phone" value="{{ $customer['phone'] }}" v-validate="'required'"> {{-- <span>@{{ errors.first('phone') }}</span> --}}
<input type="text" class="control" name="phone" value="{{ $customer['phone'] }}" v-validate="'required'">
<span>@{{ errors.first('phone') }}</span>
</div>
<div class="control-group">
<label for="password">Password</label>
<input type="password" class="control" name="password">
<span>@{{ errors.first('password') }}</span>
</div>
<div class="control-group">
<label for="password">Confirm Password</label>
<input type="password" class="control" name="password">
<span>@{{ errors.first('password') }}</span>
</div>
<div class="button-group">

View File

@ -18,13 +18,13 @@
<div class="control-group" :class="[errors.has('email') ? 'has-error' : '']">
<label for="email">{{ __('shop::app.customer.login-form.email') }}</label>
<input type="text" class="control" name="email" v-validate="'required|email'">
<input type="text" 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" :class="[errors.has('password') ? 'has-error' : '']">
<label for="password">{{ __('shop::app.customer.login-form.password') }}</label>
<input type="password" class="control" name="password" v-validate="'required|min:8|max:100'">
<input type="password" class="control" name="password" v-validate="'required|min:6'" value="{{ old('password') }}">
<span class="control-error" v-if="errors.has('password')">@{{ errors.first('password') }}</span>
</div>

View File

@ -18,25 +18,25 @@
<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'">
<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'">
<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'">
<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" :class="[errors.has('password') ? 'has-error' : '']">
<label for="password">{{ __('shop::app.customer.signup-form.password') }}</label>
<input type="password" class="control" name="password" v-validate="'required|min:6'" ref="password">
<input type="password" class="control" name="password" v-validate="'required|min:6'" ref="password" value="{{ old('password') }}">
<span class="control-error" v-if="errors.has('password')">@{{ errors.first('password') }}</span>
</div>

File diff suppressed because one or more lines are too long