This commit is contained in:
parent
4ad4dc3080
commit
bb56840db7
|
|
@ -119,3 +119,8 @@ function image_resize($image, int $width = 100, int $height = 100)
|
||||||
}
|
}
|
||||||
return asset($image);
|
return asset($image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function current_language_id()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,5 @@ class Customer extends Authenticatable
|
||||||
|
|
||||||
const AUTH_GUARD = 'web_shop';
|
const AUTH_GUARD = 'web_shop';
|
||||||
|
|
||||||
protected $fillable = ['name', 'email', 'password', 'status'];
|
protected $fillable = ['name', 'email', 'password', 'status', 'avatar', 'customer_group_id', 'language_id', 'status', 'from'];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
namespace Beike\Shop\Http\Controllers\account;
|
namespace Beike\Shop\Http\Controllers\account;
|
||||||
|
|
||||||
use Beike\Models\Customer;
|
use Beike\Models\Customer;
|
||||||
|
use Beike\Shop\Services\AccountService;
|
||||||
use Beike\Shop\Http\Controllers\Controller;
|
use Beike\Shop\Http\Controllers\Controller;
|
||||||
use Beike\Shop\Http\Requests\RegisterRequest;
|
use Beike\Shop\Http\Requests\RegisterRequest;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
@ -27,13 +28,7 @@ class RegisterController extends Controller
|
||||||
|
|
||||||
public function store(RegisterRequest $request)
|
public function store(RegisterRequest $request)
|
||||||
{
|
{
|
||||||
$customer = new Customer();
|
AccountService::register($request->all());
|
||||||
$customer->name = $request->get('name', '');
|
|
||||||
$customer->email = $request->get('email');
|
|
||||||
$customer->customer_group_id = 0;
|
|
||||||
$customer->language_id = 0;
|
|
||||||
$customer->password = Hash::make($request->get('password'));
|
|
||||||
$customer->save();
|
|
||||||
|
|
||||||
return redirect(shop_route('login.index'));
|
return redirect(shop_route('login.index'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* CategoryRepo.php
|
||||||
|
*
|
||||||
|
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||||
|
* @link http://www.guangdawangluo.com
|
||||||
|
* @author Edward Yang <yangjin@opencart.cn>
|
||||||
|
* @created 2022-06-16 17:45:41
|
||||||
|
* @modified 2022-06-16 17:45:41
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Beike\Shop\Repositories;
|
||||||
|
|
||||||
|
use Beike\Models\Category;
|
||||||
|
use Beike\Models\Customer;
|
||||||
|
use Beike\Shop\Http\Resources\CategoryList;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
|
||||||
|
class CustomerRepo
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 创建一个customer记录
|
||||||
|
*/
|
||||||
|
public static function create($customerData)
|
||||||
|
{
|
||||||
|
return Customer::query()->insertGetId([
|
||||||
|
'name' => $customerData['name'],
|
||||||
|
'email' => $customerData['email'],
|
||||||
|
'password' => $customerData['password'],
|
||||||
|
'status' => $customerData['status'],
|
||||||
|
'avatar' => $customerData['avatar'],
|
||||||
|
'customer_group_id' => $customerData['customer_group_id'],
|
||||||
|
'language_id' => $customerData['language_id'],
|
||||||
|
'status' => $customerData['status'],
|
||||||
|
'from' => $customerData['from'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* CartService.php
|
||||||
|
*
|
||||||
|
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||||
|
* @link http://www.guangdawangluo.com
|
||||||
|
* @author Sam Chen <sam.chen@opencart.cn>
|
||||||
|
* @created 2022-01-05 10:12:57
|
||||||
|
* @modified 2022-01-05 10:12:57
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Beike\Shop\Services;
|
||||||
|
|
||||||
|
|
||||||
|
use Beike\Models\Cart;
|
||||||
|
use Beike\Models\ProductSku;
|
||||||
|
use Beike\Shop\Repositories\CustomerRepo;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class AccountService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array $data // ['email', 'password']
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function register(array $data)
|
||||||
|
{
|
||||||
|
$data['password'] = Hash::make($data['password']);
|
||||||
|
$data['customer_group_id'] = setting('default_customer_group_id', 1); // default_customer_group_id为默认客户组名称
|
||||||
|
$data['status'] = !setting('approve_customer'); // approve_customer为是否需要审核客户
|
||||||
|
$data['from'] = $data['from'] ?? 'pc';
|
||||||
|
$data['language_id'] = current_language_id();
|
||||||
|
$data['name'] = '';
|
||||||
|
$data['avatar'] = '';
|
||||||
|
|
||||||
|
return CustomerRepo::create($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue